public abstract class Menu<O extends OutputManager<?>> extends AbstractContainer<O> implements WidgetWithConfig<MenuConfig>
Menu client abstract implementation class.| Modifier and Type | Class and Description |
|---|---|
static class |
Menu.PopupKeyListener
Key listener, intended to show pop-up menu.
|
| Modifier and Type | Field and Description |
|---|---|
private MenuConfig |
config
Menu attribute container.
|
private java.lang.Runnable |
menuClosed
Executed when a menu item is selected
|
listeners, location, mousePtr, nativeInsets, physicalLocation| Constructor and Description |
|---|
Menu(WidgetId id,
MenuConfig cfg)
Special constructor used to restore component using given configuration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterConfigUpdate(MenuConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
MenuConfig |
config()
Provide access to the attributes stored in the widget.
|
Widget<O> |
currentFocus(boolean recurse)
Get widget which is in focus.
|
private boolean |
delegateToProcessAccelerator(KeyInput event)
The helper method that delegates accelerator key to processAccelerator.
|
void |
destroy()
Destroy this widget.
|
void |
doShowPopup(Widget<O> src,
NativePoint location,
java.lang.Runnable dismissHandler)
The abstract portion of the logic making pop-up menu shown.
|
void |
enterMenu()
Activates the menu.
|
private MenuItem<O> |
findMenuItem(int accelCode,
AbstractContainer<O> menu)
Find MENU-ITEM by specified accelerator key code in specified MENU (SUB-MENU) recursively.
|
protected void |
focusWorker(boolean direction)
Search for the next or previous focusable widget in the container and
set focus on it.
|
abstract Widget<O> |
getFirstEnabledWidget()
Looks up the very first enabled widget.
|
static Menu<?> |
getMenu(MenuElement<?> mel)
Get menu widget from menu-item or sub-menu.
|
java.util.List<Widget<O>> |
getTabItemList()
Returns the tab item list for this container.
|
boolean |
hasFocus()
Check if widget has focus.
|
static boolean |
hasMenuFocus(MenuStructure element)
Checks whether the menu of the passed in menu element has focus, i.e.
|
void |
initialize(WidgetId id,
MenuConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
static boolean |
isMenubarElement(Widget<?> item)
Check if this menu-item is right inside MENUBAR (first level)
|
void |
leaveMenu()
Close all opened bodies and remove focus from the menu.
|
protected boolean |
processAccelerator(KeyInput event,
MenuItem<?> m)
Process accelerator event.
|
void |
processKeyAccelerator(KeyInput event)
Processes menu key accelerator event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
void |
setMenuClosedHandler(java.lang.Runnable menuClosed)
Sets a handler that will be executed when a menu item is selected.
|
void |
setVisible(boolean visible)
Hide/show widget.
|
void |
showPopup(Widget<O> src,
NativePoint location,
java.lang.Runnable dismissHandler)
Shows this pop-up menu.
|
void |
triggerMenuClosed()
Triggers the menu-closed event handler.
|
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, copyState, currentFocus, cycleFocus, defaultFocus, deregisterSelectedWidget, detach, dimension, doLayout, draw, dumpCurrentWidgets, dumpWidgets, endSizeChange, findMouseSource, firstFocus, focus, focusTraversable, formatDump, get, getAllSelectedWidgets, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, hasFocusable, height, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, paintOnTop, parentOf, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChanged, registerSelectedWidget, remove, removeContainerStateListener, repaint, replace, requestFocus, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setPhysicalDimensionInt, setSize, setSize, setTabItemList, setWidth, startSizeChange, swap, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList, widgetStateChanged, width_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hasTooltip, hidden, hide, highlighted, ignoreAction, initialHeight, initialWidth, isCurrent, isDirectManipulationActive, isDirectManipulationActiveOrInUIB, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, reflectSizeChanged, refresh, registerWidgetListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setDirectManipulationActive, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setMousePointer, setParent, setPhysicalLocation, setSensitiveForUIB, setState, setWindow, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, triggerLocationChanged, unregisterWidgetListener, updateSystemParent, widgetRealized, windowclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitwidgetsAsListacceptsEscAsAnyKey, acceptTrigger, addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, completeTrigger, defaultMousePtr, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getIdForTrigger, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasTooltip, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, isCurrent, isCurrent, isDirectManipulable, isDirectManipulationActive, isDirectManipulationActiveOrInUIB, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isProcessProgressEvent, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetListener, repaint, repaint, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setDirectManipulationActive, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setMousePointer, setParent, setPhysicalLocation, setSensitiveForUIB, setState, setWindow, show, startTrigger, supportsCustomMousePointer, systemFocusGrabbed, topLevelWindow, unregisterWidgetListener, validateDisplayValue, windowprivate java.lang.Runnable menuClosed
private MenuConfig config
public Menu(WidgetId id, MenuConfig cfg)
id - The widget's ID.cfg - Configuration data.public static boolean isMenubarElement(Widget<?> item)
public static boolean hasMenuFocus(MenuStructure element)
element - A menu element.true if the menu has focus.public final void showPopup(Widget<O> src, NativePoint location, java.lang.Runnable dismissHandler)
src - Source widget.location - The popup location.dismissHandler - When not null, the runnable instance is executed when the popup menu is dismissed, regardless
whether an item is chosen or not.public static Menu<?> getMenu(MenuElement<?> mel)
public abstract Widget<O> getFirstEnabledWidget()
nullpublic void initialize(WidgetId id, MenuConfig cfg)
This API is called after the widget is created and added to the registry.
initialize in interface WidgetWithConfig<MenuConfig>id - The widget's ID.cfg - The config used to initialize this widget.public MenuConfig config()
config in interface Widget<O extends OutputManager<?>>config in interface ConfigOwner<MenuConfig>config in class AbstractWidget<O extends OutputManager<?>>public void afterConfigUpdate(MenuConfig beforeUpdate)
afterConfigUpdate in interface ConfigOwner<MenuConfig>beforeUpdate - Config reference capturing the config state before
the owner's config was modified.public void setVisible(boolean visible)
If the menu is being shown and not yet attached to a window, attached it to the default window.
setVisible in interface Widget<O extends OutputManager<?>>setVisible in class AbstractWidget<O extends OutputManager<?>>visible - New visible state.public boolean hasFocus()
hasFocus in interface Widget<O extends OutputManager<?>>true if widget has focus.public Widget<O> currentFocus(boolean recurse)
The method allows to choose whether the focused widget is searched in the nested
containers (recurse == true) or whether only this container is searched
(recurse == false).
currentFocus in interface Container<O extends OutputManager<?>>currentFocus in class AbstractContainer<O extends OutputManager<?>>recurse - The parameter controls whether the method should recurse to the nested
containers when searching for the focused widget.public void processKeyEvent(KeyInput event)
processKeyEvent in interface Widget<O extends OutputManager<?>>processKeyEvent in class AbstractContainer<O extends OutputManager<?>>event - Key event to process.public void processKeyAccelerator(KeyInput event)
event - The key event.public java.util.List<Widget<O>> getTabItemList()
getTabItemList in interface Container<O extends OutputManager<?>>getTabItemList in class AbstractContainer<O extends OutputManager<?>>public void enterMenu()
public void leaveMenu()
protected boolean processAccelerator(KeyInput event, MenuItem<?> m)
event - KeyInput object, related to key event.m - Target accelerator source menu-item.true means accelerator was processed.
false means accelerator was ignored.public void destroy()
destroy in interface Widget<O extends OutputManager<?>>destroy in class AbstractContainer<O extends OutputManager<?>>public void setMenuClosedHandler(java.lang.Runnable menuClosed)
menuClosed - May be null.public void triggerMenuClosed()
protected void focusWorker(boolean direction)
focusWorker in class AbstractContainer<O extends OutputManager<?>>direction - Widget search direction.public void doShowPopup(Widget<O> src, NativePoint location, java.lang.Runnable dismissHandler)
src - Source widget.location - The popup location.dismissHandler - When not null, the runnable instance is executed when the popup menu is dismissed, regardless
whether an item is chosen or not.private boolean delegateToProcessAccelerator(KeyInput event)
event - The key input eventprivate MenuItem<O> findMenuItem(int accelCode, AbstractContainer<O> menu)
accelCode - Key code of accelerator.menu - Current menu or sub-menunull