Class: Fox::FXMenuButton

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

Overview

An FXMenuButton posts a popup menu when clicked. There are many ways to control the placement where the popup will appear; first, the popup may be placed on either of the four sides relative to the menu button; this is controlled by the flags MENUBUTTON_DOWN, etc. Next, there are several attachment modes; the popup’s left/bottom edge may attach to the menu button’s left/top edge, or the popup’s right/top edge may attach to the menu button’s right/bottom edge, or both. Also, the popup may appear centered relative to the menu button. Finally, a small offset may be specified to displace the location of the popup by a few pixels so as to account for borders and so on. Normally, the menu button shows an arrow pointing to the direction where the popup is set to appear; this can be turned off by passing the option MENUBUTTON_NOARROWS.

Events

The following messages are sent by FXMenuButton 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.

Menu Button Style Flags

Any combination of the following flags can be assigned as the menu button style flags.

MENUBUTTON_AUTOGRAY

Automatically gray out when no target

MENUBUTTON_AUTOHIDE

Automatically hide when no target

MENUBUTTON_TOOLBAR

Toolbar style

MENUBUTTON_NOARROWS

Do not show arrows

Menu Button Popup Style

Any one of the following options can be assigned as the menu button’s popup style.

MENUBUTTON_DOWN

Popup window appears below menu button

MENUBUTTON_UP

Popup window appears above menu button

MENUBUTTON_LEFT

Popup window to the left of the menu button

MENUBUTTON_RIGHT

Popup window to the right of the menu button

Menu Button Attachment

Any combination of the following flags can be assigned as the menu button’s attachment flags.

MENUBUTTON_ATTACH_LEFT

Popup attaches to the left side of the menu button

MENUBUTTON_ATTACH_TOP

Popup attaches to the top of the menu button

MENUBUTTON_ATTACH_RIGHT

Popup attaches to the right side of the menu button

MENUBUTTON_ATTACH_BOTTOM

Popup attaches to the bottom of the menu button

MENUBUTTON_ATTACH_CENTER

Popup attaches to the center of the menu button

MENUBUTTON_ATTACH_BOTH

Popup attaches to both sides of the menu button

Direct Known Subclasses

FXMDIWindowButton

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, popupMenu = nil, opts = JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN, x = 0, y = 0, width = 0, height = 0, padLeft = DEFAULT_SPACING, padRight = DEFAULT_SPACING, padTop = DEFAULT_SPACING, padBottom = DEFAULT_SPACING) ⇒ FXMenuButton

Constructor



81
82
# File 'rdoc-sources/FXMenuButton.rb', line 81

def initialize(parent, text, icon=nil, popupMenu=nil, opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN, x=0, y=0, width=0, height=0, padLeft=DEFAULT_SPACING, padRight=DEFAULT_SPACING, padTop=DEFAULT_SPACING, padBottom=DEFAULT_SPACING) # :yields: theMenuButton
end

Instance Attribute Details

#attachmentObject

Attachment [Integer]



76
77
78
# File 'rdoc-sources/FXMenuButton.rb', line 76

def attachment
  @attachment
end

#buttonStyleObject

Menu button style [Integer]



70
71
72
# File 'rdoc-sources/FXMenuButton.rb', line 70

def buttonStyle
  @buttonStyle
end

The popup menu Fox::FXPopup



61
62
63
# File 'rdoc-sources/FXMenuButton.rb', line 61

def menu
  @menu
end

#popupStyleObject

Popup style [Integer]



73
74
75
# File 'rdoc-sources/FXMenuButton.rb', line 73

def popupStyle
  @popupStyle
end

#xOffsetObject

X-offset where menu pops up relative to button [Integer]



64
65
66
# File 'rdoc-sources/FXMenuButton.rb', line 64

def xOffset
  @xOffset
end

#yOffsetObject

Y-offset where menu pops up relative to button [Integer]



67
68
69
# File 'rdoc-sources/FXMenuButton.rb', line 67

def yOffset
  @yOffset
end