Class MenuWidgetBase

base class for menus

class MenuWidgetBase
  : ListWidget;

Constructors

NameDescription
this (parentMenu, item, orientation)

Fields

NameTypeDescription
_submenuOpenItemIndex int
_submenuOpenTimer ulong
menuItemAction Signal!(dcanvas.widgets.menu.MenuItemActionHandler)menu item action listener
menuItemClick Signal!(dcanvas.widgets.menu.MenuItemClickHandler)menu item click listener
_backgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
checkChange Signal!(dcanvas.widgets.widget.OnCheckHandler)checked state change event listener (bool delegate(Widget, bool))
click Signal!(dcanvas.widgets.widget.OnClickHandler)on click event listener (bool delegate(Widget))
doubleClick Signal!(dcanvas.widgets.widget.OnDoubleClickHandler)On double click event listener (bool delegate(Widget))
focusChange Signal!(dcanvas.widgets.widget.OnFocusHandler)focus state change event listener (bool delegate(Widget, bool))
itemClick Signal!(dcanvas.widgets.lists.OnItemClickHandler)Handle item click / activation (e.g. Space or Enter key press and mouse double click)
itemSelected Signal!(dcanvas.widgets.lists.OnItemSelectedHandler)Handle selection change.
keyEvent Signal!(dcanvas.widgets.widget.OnKeyHandler)key event listener (bool delegate(Widget, KeyEvent)) - return true if event is processed by handler
keyToAction Listener!(dcanvas.widgets.widget.OnKeyActionHandler)action by key lookup handler
mouseEvent Signal!(dcanvas.widgets.widget.OnMouseHandler)mouse event listener (bool delegate(Widget, MouseEvent)) - return true if event is processed by handler
onAction Signal!(dcanvas.widgets.widget.OnActionHandler)action handlers
_ignoreItemSelection MenuItem
_item MenuItem
_lastClosedPopupMenu MenuItem
_lastClosedPopupTs long
_menuTogglePreviousFocus Widget
_menuToggleState int
_openedMenu PopupMenu
_openedPopup PopupWidget
_openedPopupIndex int
_parentMenu MenuWidgetBase
_selectionChangingInProgress bool
_acceleratorMap ActionMap
_action Action
_adapter ListAdapter
_checkable bool
_checked bool
_children ObjectList!(dcanvas.widgets.widget.Widget)
_clickable bool
_clickOnButtonDown boolif true, generate itemClicked on mouse down instead mouse up event
_clientRc Rectclient area rectangle (counting padding, margins, and scrollbar)
_firstVisibleItem intfirst visible item index
_focusable bool
_focusGroup bool
_hoverItemIndex intitem with Hover state, -1 if no such item
_id stringwidget id
_itemRects Rect[]
_items ObjectList!(dcanvas.widgets.widget.Widget)direct widget items; kept outside children so ListWidget.onMouseEvent always intercepts before items, while parent pointer ensures dirty propagation
_itemSizes Point[]
_lastMeasureHeight int
_lastMeasureWidth int
_makeSelectionVisibleOnNextLayout bool
_maxScrollPosition intmaximum scroll position
_measuredHeight intheight measured by measure()
_measuredWidth intwidth measured by measure()
_needDraw booltrue to force redraw
_needLayout booltrue to force layout
_needScrollbar bool
_orientation Orientation
_ownAdapter boolwhen true, need to destroy adapter on list destroy
_ownStyle Styleown copy of style - to override some of style properties, null of no properties overriden
_parent Widgetparent widget
_popupMenu MenuItem
_pos Rectcurrent widget position, set by layout()
_sbsz Point
_scrollbar ScrollBar
_scrollPosition intscroll position - offset of scroll area
_selectedItemIndex intitem with Selected state, -1 if no such item
_selectOnHover boolwhen true, mouse hover selects underlying item
_state uintwidget state (set of flags from State enum)
_styleId stringstyle id to lookup style in theme
_tabOrder ushort
_tooltipText UIString
_totalSize inttotal height of all items for Vertical orientation, or width for Horizontal
_trackHover booldoes widget need to track mouse Hover
_visibility Visibilitywidget visibility: either Visible, Invisible, Gone
_window Windowwindow (to be used for top level widgets only!)

Properties

NameTypeDescription
menuItems[set] MenuItem
selectedMenuItemWidget[get] MenuItemWidget
thisPopup[get] PopupWidgetreturns popup this menu is located in
acceleratorMap[get] ActionMap
action[get, set] const(Action)action to emit on click
adapter[get] ListAdapterget adapter
adapter[set] ListWidgetset adapter
alignment[set] Widgetsets alignment (combined vertical and horizontal)
alignment[get] ubytereturns alignment (combined vertical and horizontal)
alpha[set] Widgetset widget drawing alpha value (0=opaque .. 255=transparent)
alpha[get] uintwidget drawing alpha value (0=opaque .. 255=transparent)
animating[get] boolreturns true is widget is being animated - need to call animate() and redraw
backgroundColor[get] uintreturns background color
backgroundColor[set] Widgetset background color for widget - override one from style
backgroundColor[set] Widgetset background color for widget - from string like "#5599CC" or "white"
backgroundDrawable[get, set] Ref!(dcanvas.graphics.resources.Drawable)background drawable
backgroundImageId[get, set] stringbackground image id
canCheck[get] bool
canClick[get] bool
canFocus[get] boolreturns true if widget is focusable and visible and enabled
checkable[get] boolwhen true, control supports Checked state
checkable[set] Widget
checked[get] boolget checked state
checked[set] Widgetset checked state
childCount[get] intreturns number of children of this widget
clickable[get] boolwhen true, user can click this control, and get onClick listeners called
clickable[set] Widget
enabled[set] Widgetchange enabled state
enabled[get] boolreturn true if state has State.Enabled flag set
focusable[get] boolwhether widget can be focused
focusable[set] Widget
focused[get] bool
focusGroup[set] Widgetset focus group flag for container widget
focusGroup[get] boolWhen focus group is set for some parent widget, focus from one of containing widgets can be moved using keyboard only to one of other widgets containing in it and cannot bypass bounds of focusGroup.
focusGroupFocused[set] Widget
focusGroupFocused[get] bool
focusRectColors[get] const(uint[])returns colors to draw focus rectangle (one for solid, two for vertical gradient) or null if no focus rect should be drawn for style
font[get] Ref!(dcanvas.graphics.fonts.Font)returns font set for widget using style or set manually
fontFace[get] stringreturns font face
fontFace[set] Widgetset font face for widget - override one from style
fontFamily[get] FontFamilyreturns font family
fontFamily[set] Widgetset font family for widget - override one from style
fontItalic[get] boolreturns font style (italic/normal)
fontItalic[set] Widgetset font style (italic/normal) for widget - override one from style
fontSize[get] intreturns font size in pixels
fontSize[set] Widgetset font size for widget - override one from style
fontWeight[get] ushortreturns font weight
fontWeight[set] Widgetset font weight for widget - override one from style
halign[get] Alignreturns vertical alignment
hasTooltip[get] boolreturns true if widget has tooltip to show
height[get] intreturns current height of widget in pixels
id[set] Widgetset widget id
id[get] stringreturns widget id, null if not set
itemCount[get] intreturns number of widgets in list
layoutHeight[get] intreturns layout height options (WRAP_CONTENT, FILL_PARENT, some constant value or percent but only for one widget in layout)
layoutHeight[set] Widgetsets layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)
layoutWeight[get] intreturns layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
layoutWeight[set] Widgetsets layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
layoutWidth[get] intreturns layout width options (WRAP_CONTENT, FILL_PARENT, some constant value or percent but only for one widget in layout)
layoutWidth[set] Widgetsets layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)
left[get] intreturns widget rectangle left position
margins[get] Rectget margins (between widget bounds and its background)
margins[set] Widgetset margins for widget - override one from style
margins[set] Widgetset margins for widget with the same value for left, top, right, bottom - override one from style
maxHeight[set] Widgetset max height constraint (SIZE_UNSPECIFIED for no constraint)
maxHeight[get] intreturns max height constraint (SIZE_UNSPECIFIED if no constraint set)
maxWidth[set] Widgetset max width constraint (SIZE_UNSPECIFIED for no constraint)
maxWidth[get] intreturns max width constraint (SIZE_UNSPECIFIED if no constraint set)
measuredHeight[get] intreturns measured height (calculated during measure() call)
measuredWidth[get] intreturns measured width (calculated during measure() call)
minHeight[set] Widgetset max height constraint (0 for no constraint)
minHeight[get] intreturns min height constraint
minWidth[set] Widgetset max width constraint (0 for no constraint)
minWidth[get] intreturns min width constraint
needDraw[get] boolitems live in items, not children — extend needDraw/needLayout so the platform sees them.
needLayout[get] boolreturns true if layout is required for widget and its children
orientation[set] ListWidgetsets linear layout orientation
orientation[get] Orientationreturns linear layout orientation (Vertical, Horizontal)
ownAdapter[set] ListWidgetset adapter, which will be owned by list (destroy will be called for adapter on widget destroy)
ownStyle[get] Styleenforces widget's own style - allows override some of style properties
padding[get] Rectget padding (between background bounds and content of widget)
padding[set] Widgetset padding for widget - override one from style
padding[set] Widgetset padding for widget to the same value for left, top, right, bottom - override one from style
parent[get] Widgetreturns parent widget, null for top level widget
parent[set] Widgetsets parent for widget
popupMenu[get] MenuItem
popupMenu[set] Widget
pos[get] Rectreturns widget rectangle
resetState[set] Widgetremove state flags (set of flags from State enum)
selectedItemIndex[set] int
selectedItemIndex[get] intSelected item index.
selectOnHover[get, set] boolwhen true, mouse hover selects underlying item
setState[set] Widgetadd state flags (set of flags from State enum)
state[set] Widgetset new widget state (set of flags from State enum)
state[get] uintwidget state (set of flags from State enum)
styleId[set] Widgetset widget style id
styleId[get] stringreturns widget style id, null if not set
tabOrder[get] ushorttab order - hint for focus movement using Tab/Shift+Tab
tabOrder[set] Widget
text[set] Widgetsets widget content text (override to support this)
text[get] dstringreturns widget content text (override to support this)
textColor[set] Widgetset text color for widget - from string like "#5599CC" or "white"
textColor[set] Widgetset text color (ARGB 32 bit value)
textColor[get] uintget text color (ARGB 32 bit value)
textFlags[set] Widgetset text flags (bit set of TextFlag enum values)
textFlags[get] uintget text flags (bit set of TextFlag enum values)
tooltipText[get, set] dstringtooltip text - when not empty, widget will show tooltips automatically; for advanced tooltips - override hasTooltip and createTooltip
top[get] intreturns widget rectangle top position
trackHover[set] Widgetset new trackHover flag value (when true, widget will change Hover state while mouse is moving)
trackHover[get] boolmouse movement processing flag (when true, widget will change Hover state while mouse is moving)
valign[get] Alignreturns horizontal alignment
visibility[get] Visibilityreturns widget visibility (Visible, Invisible, Gone)
visibility[set] Widgetsets widget visibility (Visible, Invisible, Gone)
visible[get] boolreturns true if this widget and all its parents are visible
wantsKeyTracking[get] booloverride and return true to track key events even when not focused
width[get] intreturns current width of widget in pixels
window[get] Windowreturns window (if widget or its parent is attached to window)
window[set] Windowsets window (to be used for top level widget from Window implementation). TODO: hide it from API?
isMainMenu[get] bool
overrideStateForItem[get] uintallow to override state for updating of items
stateStyle[get] const(Style)returns style for current widget state
style[get, set] const(Style)accessor to style - by lookup in theme by styleId (if style id is not set, theme base style will be used).

Methods

NameDescription
close () closes this menu - handle ESC key
deactivate (force)
findKeyAction (keyCode, flags) map key to action
handleActionStateRequest (a) override to handle specific actions state (e.g. change enabled state for supported actions)
measure (parentWidth, parentHeight) Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
onKeyEvent (event) list navigation using keys
onThemeChanged () handle theme change: e.g. reload some themed resources
onTimer (id) handle timer; return true to repeat timer event after next interval, false cancel timer
updateActionState (force) call to update state for action (if action is assigned for widget)
addChild (item) adds child, returns added item
addChildren (items) adds child, returns added item
addItem (item, index) add a widget item directly (no adapter required)
addOnCheckChangeListener (listener) helper function to add onCheckChangeListener in method chain
addOnClickListener (listener) helper function to add onClickListener in method chain
addOnFocusChangeListener (listener) helper function to add onFocusChangeListener in method chain
animate (interval) animates window; interval is time left from previous draw, in hnsecs (1/10000000 of second)
applyAlign (rc, sz) Applies alignment for content of size sz - set rectangle rc to aligned value of content inside of initial value of rc.
applyMargins (rc) Helper function: applies margins to rectangle
applyPadding (rc) Helper function: applies padding to rectangle
cancelLayout ()
cancelTimer (timerId) cancel timer - pass value returned from setTimer() as timerId parameter
canShowPopupMenu (x, y) returns true if widget can show popup menu (e.g. by mouse right click at point x,y)
child (index) returns child by index
childById (id, deepSearch) find child of specified type T by id, returns null if not found or cannot be converted to type T
childIndex (item) returns index of widget in child list, -1 if passed widget is not a child of this widget
clearItems () remove all direct widget items
compareId (id) compare widget id with specified value, returs true if matches
createTooltip (mouseX, mouseY, alignment, x, y) will be called from window once tooltip request timer expired; if null is returned, popup will not be shown; you can change alignment and position of popup here
dispatchAction (a) call to dispatch action
drawFocusRect (buf, rc) draws focus rectangle, if enabled in styles
executeInUiThread (runnable) execute delegate later in UI thread if this widget will be still available (can be used to modify UI from background thread, or just to postpone execution of action)
fillHorizontal () sets layoutWidth=FILL_PARENT
fillParent () sets layoutWidth=FILL_PARENT and layoutHeight=FILL_PARENT
fillVertical () sets layoutHeight=FILL_PARENT
findFocusableChild (defaultOnly) searches children for first focusable item, returns null if not found
focusGroupWidget () find nearest parent of this widget with focusGroup flag, returns topmost parent if no focusGroup flag set to any of parents.
getCursorType (x, y) returns mouse cursor type for widget
handleAction (a) override to handle specific actions
handleActionStateChanged () called when state of action assigned on widget is changed
handleMoveFocusUsingKeys (event)
insertChild (item, index) inserts child at given index, returns inserted item
invalidate () request redraw
isActionEnabled (action) override to change popup menu items state
isChild (item, deepSearch) returns true if item is child of this widget; also searches items subtree.
isPointInside (x, y) returns true if point is inside of this widget
isPointInside (pt)
itemByPosition (pos) returns item index by 0-based offset from top/left of list content
itemEnabled (index) returns true if item with corresponding index is enabled
itemRect (index) returns rectangle for item (scrolled)
itemRectNoScroll (index) returns rectangle for item (not scrolled, first item starts at 0,0)
itemWidget (index) return list item widget by item index
layout (rc) Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
makeItemVisible (itemIndex) ensure item is visible
makeSelectionVisible () ensure selected item is visible (scroll if necessary)
minimumVisibleContentSize () sets minimum size for the list, override to change
moveSelection (direction, wrapAround) move selection
onAdapterChange (source) item list is changed
onDraw (buf) Draw widget at its position to buffer
onEvent (event) handle custom event
onMenuItemAction (action)
onMouseEvent (event) process mouse event; return true if event is processed by widget.
onScrollEvent (source, event) handle scroll event
removeAllChildren (destroyObj)
removeChild (child) removes child, returns removed item
removeChild (ID) removes child by ID, returns removed item
removeChild (index) removes child, returns removed item
removeItem (index) remove a widget item by index and destroy it
replaceChild (newChild, oldChild) replace child with other child
requestActionsUpdate (immediateUpdate) set action update request flag, will be cleared after redraw
requestLayout () request relayout of widget and its children
resetItemState (index, flags) reset one or more list item's state flags
scheduleTooltip (delay, alignment, x, y) schedule tooltip
selectItem (index)
selectItem (index, disabledItemsSkipDirection)
setBoolProperty (name, value) set string property value, for ML loaders
setDoubleProperty (name, value) set double property value, for ML loaders
setDstringProperty (name, value) set string property value, for ML loaders
setFocus (reason) sets focus to this widget or suitable focusable child, returns previously focused widget
setIntProperty (name, value) set int property value, for ML loaders
setItemState (index, flags) set one or more list item's state flags
setRectProperty (name, value) set Rect property value, for ML loaders
setStringListValueListProperty (propName, values) StringListValue list values
setStringProperty (name, value) set string property value, for ML loaders
setTimer (intervalMillis) set new timer to call onTimer() after specified interval (for recurred notifications, return true from onTimer)
setUIStringListProperty (propName, values) UIString list values
setUistringProperty (name, value) set string property value, for ML loaders
showPopupMenu (x, y) shows popup menu at (x,y)
updateActionState (a, force, allowDefault) ask for update state of some action (unles force=true, checks window flag actionsUpdateRequested), returns true if action state is changed
updateStateFromAction (a) apply enabled, visibile and checked state for this widget from action's state
cancelOpenSubmenu ()
handleMenuItemClick (item)
isRecentlyClosedItem (item)
itemClicked (index) override to handle mouse up on item
onMenuItem (item)
onPopupClosed (p)
openSubmenu (index, itemWidget)
performUndoSelection ()
scheduleOpenSubmenu (index)
selectionChanged (index, previouslySelectedItem) override to handle change of selection
handleCheckChange (checked) override to handle check changes
handleClick ()
handleDoubleClick ()
handleFocusChange (focused, receivedFocusFromKeyboard) override to handle focus changes
handleFontChanged () override to handle font changes
itemState (index) return list item's state flags
measuredContent (parentWidth, parentHeight, contentWidth, contentHeight) helper function for implement measure() when widget's content dimensions are known
measureMinChildrenSize ()
setHoverItem (index)
setWindowFocusedFlag (flg)
updateItemPositions ()
updateSelectedItemFocus ()

Aliases

NameDescription
~this