Class: Fox::FXButton

Inherits:
FXLabel show all
Defined in:
rdoc-sources/FXButton.rb

Overview

A button provides a push button, with optional icon and/or text label. When pressed, the button widget sends a SEL_COMMAND to its target. Passing the BUTTON_TOOLBAR style option gives buttons a “flat” look, and causes the edge of the button to be raised when the cursor moves over it. Passing BUTTON_DEFAULT allows the button to become the default button in a dialog, when the focus moves to it. The default widget in a dialog is the widget which will accept the Return key when it is pressed. The BUTTON_INITIAL flag makes the button the default widget when the focus moves to a widget which can not itself be a default widget. There should be only a single button in the dialog which is the initial default; typically this is the OK or Close button. The option BUTTON_AUTOGRAY (BUTTON_AUTOHIDE) causes the button to be grayed out (hidden) if its handler does not respond to the SEL_UPDATE message. This is useful when messages are delegated, for example when using a multiple document interface, where the ultimate destination of a message can be changed.

Events

The following messages are sent by FXButton to its target:

SEL_KEYPRESS

sent when a key goes down; the message data is an FXEvent instance.

SEL_KEYRELEASE

sent when a key goes up; the message data is an FXEvent instance.

SEL_LEFTBUTTONPRESS

sent when the left mouse button goes down; the message data is an FXEvent instance.

SEL_LEFTBUTTONRELEASE

sent when the left mouse button goes up; the message data is an FXEvent instance.

SEL_COMMAND

sent when the button is clicked.

Button state bits

STATE_UP

Button is up

STATE_DOWN

Button is down

STATE_ENGAGED

Button is engaged

STATE_UNCHECKED

Same as STATE_UP (used for check buttons or radio buttons)

STATE_CHECKED

Same as STATE_ENGAGED (used for check buttons or radio buttons)

Button flags

BUTTON_AUTOGRAY

Automatically gray out when not updated

BUTTON_AUTOHIDE

Automatically hide button when not updated

BUTTON_TOOLBAR

Toolbar style button [flat look]

BUTTON_DEFAULT

May become default button when receiving focus

BUTTON_INITIAL

This button is the initial default button

BUTTON_NORMAL

Default button flags (FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT)

Instance Attribute Summary collapse

Attributes inherited from FXLabel

#font, #helpText, #icon, #iconPosition, #justify, #text, #textColor, #tipText

Attributes inherited from FXFrame

#baseColor, #borderColor, #borderWidth, #frameStyle, #hiliteColor, #padBottom, #padLeft, #padRight, #padTop, #shadowColor

Attributes inherited from FXWindow

#accelTable, #backColor, #defaultCursor, #dragCursor, #first, #focus, #key, #last, #layoutHints, #next, #numChildren, #owner, #parent, #prev, #root, #selector, #shell, #target, #x, #y

Attributes inherited from FXDrawable

#height, #visual, #width

Attributes inherited from FXId

#app, #userData, #xid

Instance Method Summary collapse

Methods inherited from FXLabel

#to_s

Methods inherited from FXWindow

#acceptDrop, #acquireClipboard, #acquireSelection, #active?, #addHotKey, #after?, after?, #before?, before?, #beginDrag, #canFocus?, #changeFocus, #childAtIndex, #childOf?, #children, #clearDragRectangle, #clearShape, colorType, colorTypeName, commonAncestor, #composeContext, #composite?, #contains?, #containsChild?, #create, #createComposeContext, #cursorPosition, #default?, #defaultHeight, #defaultWidth, deleteType, deleteTypeName, #destroy, #destroyComposeContext, #detach, #didAccept, #disable, #doesSaveUnder?, #dragging?, #dropDisable, #dropEnable, #dropEnabled?, #dropFinished, #dropTarget?, #each_child, #each_child_recursive, #enable, #enabled?, #endDrag, #forceRefresh, #getChildAt, #getDNDData, #getHeightForWidth, #getWidthForHeight, #grab, #grabKeyboard, #grabbed?, #grabbedKeyboard?, #handleDrag, #hasClipboard?, #hasFocus?, #hasSelection?, #height, #height=, #hide, imageType, #inFocusChain?, #indexOfChild, #initial?, #inquireDNDAction, #inquireDNDTypes, #killFocus, #layout, #linkAfter, #linkBefore, #lower, #move, octetType, octetTypeName, #offeredDNDType?, #position, #raiseWindow, #recalc, #releaseClipboard, #releaseSelection, #remHotKey, #removeChild, #repaint, #reparent, #resize, #scroll, #setCursorPosition, #setDNDData, #setDefault, #setDragRectangle, #setFocus, #setInitial, #setShape, #shell?, #show, #shown?, stringType, textType, textTypeName, #tr, #translateCoordinatesFrom, #translateCoordinatesTo, #underCursor?, #ungrab, #ungrabKeyboard, #update, urilistType, urilistTypeName, utf16Type, utf16TypeName, utf8Type, utf8TypeName, #visible=, #width, #width=

Methods included from Responder2

#connect

Methods inherited from FXDrawable

#resize

Methods inherited from FXId

#create, #created?, #destroy, #detach, #runOnUiThread

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(parent, text, icon = nil, target = nil, selector = 0, opts = BUTTON_NORMAL, x = 0, y = 0, width = 0, height = 0, padLeft = DEFAULT_PAD, padRight = DEFAULT_PAD, padTop = DEFAULT_PAD, padBottom = DEFAULT_PAD) ⇒ FXButton

Construct button with specified text and icon.



56
57
# File 'rdoc-sources/FXButton.rb', line 56

def initialize(parent, text, icon=nil, target=nil, selector=0, opts=BUTTON_NORMAL, x=0, y=0, width=0, height=0, padLeft=DEFAULT_PAD, padRight=DEFAULT_PAD, padTop=DEFAULT_PAD, padBottom=DEFAULT_PAD) # :yields: theButton
end

Instance Attribute Details

#buttonStyleObject

Button style flags (some combination of BUTTON_AUTOGRAY, BUTTON_AUTOHIDE, etc.) [Integer]



53
54
55
# File 'rdoc-sources/FXButton.rb', line 53

def buttonStyle
  @buttonStyle
end

#stateObject

Button state (one of STATE_UP, STATE_DOWN, etc.) [Integer]



50
51
52
# File 'rdoc-sources/FXButton.rb', line 50

def state
  @state
end