Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Gui.Button Class Reference

Button widget. More...

Inheritance diagram for Dragengine.Gui.Button:
Dragengine.Gui.Container Dragengine.Gui.Widget Dragengine.Gui.BgButton Dragengine.Gui.ToggleButton Dragengine.Gui.CheckBox Dragengine.Gui.OptionBox

Public Member Functions

void createContentWidgets ()
 Create button content widgets.
void dispose ()
void fireAction (int modifiers)
Image getHoverImage ()
 Hover image or null to use regular image.
Image getImage ()
bool getPressed ()
String getText ()
 Text of the button.
Button new ()
 Create button.
Button new (String text, ActionListener action)
 Create text button.
Button new (String text, Image image)
 Create text and image button.
Button new (String text, Image image, ActionListener action)
 Create text and image button.
void onButtonPress (MouseEvent event)
void onButtonRelease (MouseEvent event)
void onFocusLost (FocusEvent event)
 Widget lost focus.
void onFocusReceived (FocusEvent event)
 Widget received focus.
void onGuiThemeChanged ()
 Gui theme changed.
void onKeyPress (KeyEvent event)
void onKeyRelease (KeyEvent event)
void onMouseEnter (MouseEvent event)
void onMouseMove (MouseEvent event)
void removeActionListener (ActionListener listener)
void setHoverImage (Image image)
 Set hover image or null to use regular image.
void setImage (Image image)
void setPressed (bool pressed)
void setText (String text)
 Set text of the button.
void updateWidgetImage ()
 Update image to display depending on current button state.
Public Member Functions inherited from Dragengine.Gui.Container
void addWidget (Widget widget)
void addWidget (Widget widget, Object settings)
bool allowsChildGrabFocus ()
void collectClosestFocusWidget (ClosestDirectionFocusFinder finder, Point origin)
 Find closest focus widget for directional navigation.
void doLayout ()
Widget findFocusableWidget ()
Widget findLastFocusableWidget ()
Widget findWidget (Block ablock)
 Find widget using block or null if not found.
int getContainerHeight ()
Point getContainerSize ()
int getContainerWidth ()
bool getHasBlockedDoLayout ()
 doLayout calls happened during runWhileBlockingLayout.
Layout getLayout ()
Point getMinimumSize ()
Point getMinimumSizeForHeight (int height)
 Minimum size of widget using reference widget height and variable width.
Point getMinimumSizeForWidth (int width)
 Minimum size of widget using reference widget width and variable height.
bool getStateChangeNotifyChildren ()
 Notify children if state changed.
Widget getWidget (int index)
Widget getWidgetAt (Point position)
 Widget at coordinates or null if not found.
int getWidgetCount ()
void giveUpFocus ()
bool hasFocusWidget ()
 Focus widget is inside container somewhere.
bool hasWidget (Widget widget)
int indexOfWidget (Widget widget)
Object injectWidget (Object injectValue, Block ablock)
 Process value visiting widgets using block.
bool isChildVisible (Widget child)
 Child widget is visible.
bool isChildVisibleOnDesktop (Widget child)
 Child widget is visible on desktop.
bool isMouseInside ()
 Mouse is hovering over this widget.
void layoutParent ()
void moveWidget (Widget widget, int newPosition)
Container new (int x, int y, int width, int height)
Container new (Layout layout)
 Create container with layout.
Container new (Layout layout, Block blockAddContent)
 Create container with layout calling block to add content.
Container new (Point position, Point size)
Widget nextFocusWidgetAfter (Widget widget)
 Find next widget in the focus cycle that can grab the focus.
void onPaddingChanged ()
 Padding changed.
void onStateChanged (StateChangeEvent event)
 State changed.
Widget prevFocusWidgetAfter (Widget widget)
 Find previous widget in the focus cycle that can grab the focus.
void removeAllWidgets ()
 Remove and dispose all widgets.
void removeWidget (Widget widget)
 Remove widget without disposing.
bool requestCaptureDirectional (Widget widget)
 Request to capture directional navigation for the specified widget.
bool requestCaptureMouse (Widget widget)
bool requestReleaseDirectional (Widget widget)
 Request to release directional navigation capture.
bool requestReleaseMouse (Widget widget)
void runWhileBlockingLayout (Block ablock)
 Run block while layouting is blocked.
void setEnabled (bool enabled)
void setHasBlockedDoLayout (bool hasBlockedDoLayout)
 Set if doLayout calls happened during runWhileBlockingLayout.
void setLayout (Layout layout)
void setMousePointer (MousePointerFactory mousePointer)
 Set mouse pointer to use.
void setStateChangeNotifyChildren (bool notify)
 Set to notify children if state changed.
Public Member Functions inherited from Dragengine.Gui.Widget
void addDragListener (DragListener listener)
void addFocusListener (FocusListener listener)
 Add focus listener.
void addGamepadListener (GamepadListener listener)
 Add gamepad listener.
void addKeyListener (KeyListener listener)
void addMouseListener (MouseListener listener)
void addStateChangeListener (StateChangeListener listener)
 Add state change listener.
void addWidgetListener (WidgetListener listener)
 Add widget listener.
bool canGrabFullFocus ()
void captureDirectional ()
 Captures directional navigation if not already captured by another widget.
void design ()
 Design widget using WidgetDesigner.
void desktopWarpMouseFocusHere ()
 Warp mouse to focus location on this widget.
void desktopWarpMouseFocusLocation ()
 Warp mouse to focus location on desktop focus widget.
void ensureVisible ()
 Ensure widget is fully visible on desktop if possible.
void ensureVisible (RectArea boundary)
 Ensure boundary is visible on desktop if possible.
void focusDirectional (int direction)
 Focus widget in direction that can grab the focus.
CanvasCreator getBackgroundCanvasCreator ()
 Background canvas creator or null to use background color.
bool getBlockLayoutParent ()
 Block layoutParent calls.
Border getBorder ()
BorderSize getBorderSize ()
RectArea getBoundary ()
 Rectangular boundary of the widget.
RectArea getBoundaryWithBorder ()
 Rectangular boundary of the widget including border.
bool getCanFocus ()
bool getCanFocusDirectional ()
 Widget can get focus using directional navigation.
CanvasView getCanvasBackground ()
CanvasView getCanvasContent ()
CanvasView getCanvasWidget ()
Clipboard getClipboard ()
 Clipboard or null to use parent clipboard.
ColorMatrix getColorTransformation ()
 Color transformation.
WidgetDesigner getDesigner ()
 Designer.
String getDesignerSelector ()
 Designer selector.
Desktop getDesktop ()
RectArea getDesktopBoundary ()
 Rectangular boundary of widget relative to desktop.
RectArea getDesktopBoundaryWithBorder ()
 Rectangular boundary of widget including border relative to parent.
Point getDesktopPosition ()
 Widget position in desktop coordinates.
Widget getDirectionalCaptureWidget ()
 Widget having captured directional navigation.
bool getEnabled ()
MousePointerFactory getFirstMousePointer ()
 First assigned mouse pointer.
Point getFocusMouseLocation ()
 Focus mouse location in widget coordinates.
Font getFont ()
bool getHasBlockedLayoutParent ()
 layoutParent calls happened during runWhileBlockingLayoutParent.
bool getHasFocus ()
int getHeight ()
 Height of widget.
RangeModel getHorizontalRangeModel ()
 Horizontal range model for viewports to synchronize the horizontal scrollbar.
Widget getHoverWidget ()
 Widget the mouse hovers above or null.
Point getLocalMouseLocation ()
 Parent desktop mouse location in widget coordinates.
Point getMinimumSizeWithBorder ()
Point getMinimumSizeWithBorderForHeight (int height)
 Minimum size of widget with border using reference height.
Point getMinimumSizeWithBorderForWidth (int width)
 Minimum size of widget with border for reference width.
Widget getMouseCaptureWidget ()
 Widget having captured the mouse.
MousePointerFactory getMousePointer ()
 Mouse pointer to use.
BorderSize getPadding ()
 Padding.
Container getParent ()
Point getPosition ()
 Position of the widget.
bool getProtectBackgroundCanvasCreator ()
 Protect custom set background canvas creator.
bool getProtectBorder ()
 Protect custom set border.
bool getProtectFont ()
 Protect custom set font.
bool getProtectMinimumSize ()
 Protect custom set minimumsize.
bool getProtectMousePointer ()
 Protect custom set mouse pointer.
bool getProtectPadding ()
 Protect custom set padding.
bool getProtectTextColor ()
 Protect custom set text color.
RectArea getRelativeBoundary (Container parent)
 Rectangular boundary of widget relative to parent.
RectArea getRelativeBoundaryWithBorder (Container parent)
 Rectangular boundary of widget including border relative to parent.
Point getRelativePosition (Container parent)
 Widget position in parent widget coordinates.
Point getScreenPosition ()
 Widget position in screen coordinates.
RectArea getScreenRectArea ()
Point getSetMinimumSize ()
Point getSize ()
 Size of the widget.
Color getTextBorderColor ()
 Text border color.
float getTextBorderThickness ()
 Text border thickness in percentage of the font size or null.
Color getTextColor ()
 Text color.
float getTextDilation ()
 Text dilation in percentage of the font size.
String getTitle ()
 Widget title.
Object getToolTip ()
 Tooltip or null.
float getTotalTransparency ()
TexMatrix2 getTransformation ()
float getTransparency ()
RangeModel getVerticalRangeModel ()
 Vertical range model for viewports to synchronize the vertical scrollbar.
bool getVisible ()
RectArea getVisibleDesktopBoundary ()
 Visible widget boundary in desktop coordinates.
RectArea getVisibleRelativeBoundary (Container parent)
 Visible widget boundary relative to parent coordinate system.
int getWidth ()
 Width of widget.
Window getWindow ()
Point getWindowPosition ()
 Widget position in window coordinates.
int getX ()
 X position of widget.
int getY ()
 Y position of widget.
void grabFocus ()
bool hasParent (Container container)
bool isCapturingDirectional ()
 Widget is capturing directional navigation.
bool isCapturingMouse ()
 Widget is capturing mouse.
bool isDesignerSet ()
 Custom designer is set.
bool isFullEnabled ()
 Widget and all parent widgets are enabled.
bool isMinimumSizeSet ()
bool isPointInside (Point position)
bool isTransformationSet ()
void layoutParentIfBlocked ()
 Calls layoutParent if getHasBlockedLayoutParent() is true.
Widget nextFocusWidget ()
 Find next widget in the focus cycle that can grab the focus.
void notifyBorderParametersChanged ()
void onDesignerChanged ()
 Designer changed.
void onDesignerSelectorChanged ()
 Designer selector changed.
void onDispose (WidgetEvent event)
 Window is disposing.
void onFrameUpdate (float elapsed)
 Do frame update.
void onGamepadButtonPressed (GamepadEvent event)
 Gamepad button has been pressed.
void onGamepadButtonReleased (GamepadEvent event)
 Gamepad button has been released.
void onHidden (WidgetEvent event)
 Widget has been hidden.
void onParentStateChanged ()
 Parent state changed.
void onParentStateChanged (bool force)
 Parent state changed.
void onReposition (WidgetEvent event)
 Position changed.
void onResize (WidgetEvent event)
 Size changed.
void onSetFont ()
void onSetTextColor ()
 Text parameters changed.
void onSetTextDilation ()
 Text parameters changed that affect text dilation.
void onShown (WidgetEvent event)
 Widget has been shown.
void onTranslationChanged ()
 Translation manager or active language pack changed.
void popdownVirtualKeyboard ()
 Popdown virtual keyboard if Desktop has one assigned.
void popdownVirtualKeyboardDirectional ()
 Popdown virtual keyboard if Desktop has one assigned and direction focus widget.
void popupVirtualKeyboard ()
 Popup virtual keyboard if Desktop has one assigned.
Widget prevFocusWidget ()
 Find previous widget in the focus cycle that can grab the focus.
void processEvent (Event event)
 Process an event.
void releaseDirectional ()
 Release directional navigation capture.
void releaseMouse ()
void removeDragListener (DragListener listener)
void removeFocusListener (FocusListener listener)
 Remove focus listener.
void removeGamepadListener (GamepadListener listener)
 Remove gamepad listener.
void removeKeyListener (KeyListener listener)
void removeMouseListener (MouseListener listener)
void removeStateChangeListener (StateChangeListener listener)
 Remove state change listener.
void removeWidgetListener (WidgetListener listener)
 Remove widget listener.
void requestGrabFocus (Widget widget)
void runWhileBlockingLayoutParent (Block ablock)
 Run block while layouting is blocked.
void safeDispose ()
 Safely dispose of widget.
void sendEvent (Event event)
void sendEventToListeners (Event event, bool sendToParent)
 Send event to all appropriate listeners for events of its kind.
void setBackgroundCanvasCreator (CanvasCreator creator)
 Set background canvas creator or null to use background color.
void setBlockLayoutParent (bool blockLayoutParent)
 Set block layoutParent calls.
void setBorder (Border border)
void setCanFocus (bool canFocus)
void setCanFocusDirectional (bool canFocus)
 Set if widget can get focus using directional navigation.
void setClipboard (Clipboard clipboard)
 Set clipboard or null to use parent clipboard.
void setColorTransformation (ColorMatrix transformation)
 Set color transformation.
void setDesigner (WidgetDesigner designer)
 Set designer.
void setDesignerSelector (String selector)
 Set designer selector.
void setFont (Font font)
void setHasBlockedLayoutParent (bool hasBlockedLayoutParent)
 Set if layoutParent calls happened during runWhileBlockingLayoutParent.
void setHasFocus (bool hasFocus)
void setHeight (int height)
 Set height of widget.
void setMinimumSize (Point size)
void setPadding (BorderSize padding)
 Set padding.
void setParent (Container parent)
void setPosition (Point position)
 Set position of widget.
void setProtectBackgroundCanvasCreator (bool protect)
 Set protect custom set background canvas creator.
void setProtectBorder (bool protect)
 Set protect custom set border.
void setProtectFont (bool protect)
 Set protect custom set font.
void setProtectMinimumSize (bool protect)
 Set protect custom set minimumsize.
void setProtectMousePointer (bool protect)
 Set protect custom set mouse pointer.
void setProtectPadding (bool protect)
 Set protect custom set padding.
void setProtectTextColor (bool protect)
 Set protect custom set text color.
void setSize (Point size)
 Set size of widget.
void setTextBorderColor (Color color)
 Set text border color.
void setTextBorderThickness (float thickness)
 Set text border thickness in percentage of the font size or null.
void setTextColor (Color color)
 Set text color.
void setTextDilation (float dilation)
 Set text dilation in percentage of the font size.
void setTitle (String title)
 Set widget title.
void setToolTip (Object toolTip)
 Set tooltip or null.
void setTransformation (TexMatrix2 transformation)
void setTransparency (float transparency)
void setVisible (bool visible)
void setWidth (int width)
 Set width of widget.
void setX (int x)
 Set X position of widget.
void setY (int y)
 Set Y Position of widget.
void simulateKeyPress (int keyCode, int keyChar)
 Simulate keyboard press event.
void simulateKeyPressRelease (int keyCode, int keyChar)
 Simulate keyboard press and release event.
void simulateKeyRelease (int keyCode, int keyChar)
 Simulate keyboard release event.
void startFrameUpdater ()
 Start frame updater if not running.
void stopFrameUpdater ()
 Stop frame updater if running.

Public Attributes

Array pActionListeners
bool pHasGrab
Image pHoverImage
Image pImage
bool pPressed
String pText
DisplayImage pWidgetImage
Label pWidgetText
Public Attributes inherited from Dragengine.Gui.Container
bool pBlockLayout
Point pCachedMinSize
int pCachedMinSizeForHeightHeight
Point pCachedMinSizeForHeightSize
Point pCachedMinSizeForWidthSize
int pCachedMinSizeForWidthWidth
Array pChildren
bool pHasBlockedDoLayout
Layout pLayout
bool pStateChangeNotifyChildren
Public Attributes inherited from Dragengine.Gui.Widget
CanvasCreator pBackgroundCanvasCreator
bool pBlockLayoutParent
Border pBorder
CanvasView pCanvasWidget
Clipboard pClipboard
WidgetDesigner pDesigner
String pDesignerSelector
Font pFont
FrameUpdater pFrameUpdater
bool pIsDesignerSet
Array pKeyListeners
MousePointerFactory pMousePointer
BorderSize pPadding
Container pParent
Point pPosition
bool pProtectBackgroundCanvasCreator
RepeatKeyEventTimer pRepeatEventTimer
float pTextBorderThickness
Color pTextColor
GuiTheme pTheme
String pThemeSelector
String pTitle
Object pToolTip
TexMatrix2 pTransformation
TranslationManager pTranslationManager
float pTransparency
bool pVisible

Protected Member Functions

DisplayImage getWidgetImage ()
 Image or null if not used.
void setWidgetImage (DisplayImage widget)
 Set image or null if not used.
void setWidgetText (Label widget)
 Set label or null if not used.
Protected Member Functions inherited from Dragengine.Gui.Widget
WidgetDesigner getDesignerFromTheme ()
 Get designer from gui theme.
void updateCanvasBackground ()
 Update background canvas content.
void updateCanvasGeometry ()
 Update canvas position and size.

Detailed Description

Button widget.

Supports designing using designer selector 'Button'. If present the child label is designed using designer selector 'Label.Button'. If present the child display image is designed using designer selector 'Image.Button'. For best results the child label and image designer has to be a subclass of DefaultButtonWidgetDesigner.

Member Function Documentation

◆ createContentWidgets()

void Dragengine.Gui.Button.createContentWidgets ( )

Create button content widgets.

Call if the layout of the widgets changes. Removes the old widgets first.

Reimplemented in Dragengine.Gui.CheckBox, and Dragengine.Gui.OptionBox.

Referenced by updateWidgetImage().

◆ dispose()

void Dragengine.Gui.Button.dispose ( )

Disposes of the widget. This cleans all references and prepars the widget for beeing freed. If the widget is already disposed nothing happens.

Reimplemented from Dragengine.Gui.Widget.

Reimplemented in Dragengine.Gui.BgButton, Dragengine.Gui.CheckBox, Dragengine.Gui.OptionBox, and Dragengine.Gui.ToggleButton.

References new(), and setText().

Referenced by getPressed(), and removeActionListener().

◆ fireAction()

void Dragengine.Gui.Button.fireAction ( int modifiers)

Fire button press action.

References getText(), and pText.

Referenced by Dragengine.Gui.ToggleButton.toggledChanged(), and updateWidgetImage().

◆ getHoverImage()

Image Dragengine.Gui.Button.getHoverImage ( )

Hover image or null to use regular image.

References new().

Referenced by onGuiThemeChanged().

◆ getImage()

Image Dragengine.Gui.Button.getImage ( )

Image of the button.

Reimplemented in Dragengine.Gui.BgButton.

References new().

Referenced by onFocusReceived().

◆ getPressed()

bool Dragengine.Gui.Button.getPressed ( )

◆ getText()

String Dragengine.Gui.Button.getText ( )

◆ getWidgetImage()

DisplayImage Dragengine.Gui.Button.getWidgetImage ( )
protected

Image or null if not used.

References pHoverImage, and setHoverImage().

Referenced by updateWidgetImage().

◆ new() [1/4]

Button Dragengine.Gui.Button.new ( )

◆ new() [2/4]

Button Dragengine.Gui.Button.new ( String text,
ActionListener action )

Create text button.

Reimplemented in Dragengine.Gui.ToggleButton.

◆ new() [3/4]

Button Dragengine.Gui.Button.new ( String text,
Image image )

◆ new() [4/4]

Button Dragengine.Gui.Button.new ( String text,
Image image,
ActionListener action )

Create text and image button.

Reimplemented in Dragengine.Gui.ToggleButton.

◆ onButtonPress()

void Dragengine.Gui.Button.onButtonPress ( MouseEvent event)

Mouse button has been pressed.

Reimplemented in Dragengine.Gui.ToggleButton.

References pText.

Referenced by updateWidgetImage().

◆ onButtonRelease()

void Dragengine.Gui.Button.onButtonRelease ( MouseEvent event)

Mouse button has been released.

Reimplemented in Dragengine.Gui.ToggleButton.

References pWidgetText, setText(), and Dragengine.Gui.Widget.setVisible().

Referenced by updateWidgetImage().

◆ onFocusLost()

void Dragengine.Gui.Button.onFocusLost ( FocusEvent event)

Widget lost focus.

Reimplemented from Dragengine.Gui.Widget.

References pImage.

Referenced by updateWidgetImage().

◆ onFocusReceived()

void Dragengine.Gui.Button.onFocusReceived ( FocusEvent event)

Widget received focus.

Reimplemented from Dragengine.Gui.Widget.

References getImage().

Referenced by updateWidgetImage().

◆ onGuiThemeChanged()

void Dragengine.Gui.Button.onGuiThemeChanged ( )

Gui theme changed.

Reimplemented from Dragengine.Gui.Container.

References getHoverImage().

Referenced by updateWidgetImage().

◆ onKeyPress()

void Dragengine.Gui.Button.onKeyPress ( KeyEvent event)

Key on the keyboard has been pressed.

Reimplemented in Dragengine.Gui.ToggleButton.

Referenced by updateWidgetImage().

◆ onKeyRelease()

void Dragengine.Gui.Button.onKeyRelease ( KeyEvent event)

Key on the keyboard has been released.

Reimplemented in Dragengine.Gui.ToggleButton.

References setText().

Referenced by updateWidgetImage().

◆ onMouseEnter()

void Dragengine.Gui.Button.onMouseEnter ( MouseEvent event)

Notification that the mouse entered the widget. The default behaviour is to send the message to all registered listeners or propagate it back to the parent if allowed.

References updateWidgetImage().

Referenced by updateWidgetImage().

◆ onMouseMove()

void Dragengine.Gui.Button.onMouseMove ( MouseEvent event)

Mouse has moved.

Reimplemented in Dragengine.Gui.ToggleButton.

References pImage, and setImage().

Referenced by updateWidgetImage().

◆ removeActionListener()

void Dragengine.Gui.Button.removeActionListener ( ActionListener listener)

Remove action listener.

References dispose(), and pActionListeners.

Referenced by updateWidgetImage().

◆ setHoverImage()

void Dragengine.Gui.Button.setHoverImage ( Image image)

Set hover image or null to use regular image.

Referenced by getWidgetImage().

◆ setImage()

void Dragengine.Gui.Button.setImage ( Image image)

Set image of the button.

Reimplemented in Dragengine.Gui.BgButton.

Referenced by onMouseMove(), and setText().

◆ setPressed()

void Dragengine.Gui.Button.setPressed ( bool pressed)

◆ setText()

void Dragengine.Gui.Button.setText ( String text)

◆ setWidgetImage()

void Dragengine.Gui.Button.setWidgetImage ( DisplayImage widget)
protected

◆ setWidgetText()

void Dragengine.Gui.Button.setWidgetText ( Label widget)
protected

◆ updateWidgetImage()

Member Data Documentation

◆ pActionListeners

Array Dragengine.Gui.Button.pActionListeners

◆ pHasGrab

bool Dragengine.Gui.Button.pHasGrab

Referenced by updateWidgetImage().

◆ pHoverImage

Image Dragengine.Gui.Button.pHoverImage

◆ pImage

Image Dragengine.Gui.Button.pImage

Referenced by onFocusLost(), and onMouseMove().

◆ pPressed

bool Dragengine.Gui.Button.pPressed

Referenced by updateWidgetImage().

◆ pText

String Dragengine.Gui.Button.pText

Referenced by fireAction(), new(), and onButtonPress().

◆ pWidgetImage

DisplayImage Dragengine.Gui.Button.pWidgetImage

Referenced by setPressed(), and updateWidgetImage().

◆ pWidgetText

Label Dragengine.Gui.Button.pWidgetText

The documentation for this class was generated from the following file: