Class Menu
- Styles:
- BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP
- LEFT_TO_RIGHT, RIGHT_TO_LEFT
- Events:
- Help, Hide, Show
Note: Only one of BAR, DROP_DOWN and POP_UP may be specified. Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
IMPORTANT: This class is not intended to be subclassed.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) longGTK4 only fields(package private) MenuItem(package private) boolean(package private) ImageList(package private) LinkedList<MenuItem> (package private) long(package private) longGTK4 only fields(package private) Decorations(package private) int(package private) LinkedList<Menu.Section> (package private) MenuItem(package private) longGTK4 only fields(package private) int(package private) intFields inherited from class Widget
ACTIVATE, ACTIVATE_INVERSE, AUTO_TEXT_DIRECTION, BACKGROUND, BACKSPACE, BACKSPACE_INVERSE, BUTTON_PRESS_EVENT, BUTTON_PRESS_EVENT_INVERSE, BUTTON_RELEASE_EVENT, BUTTON_RELEASE_EVENT_INVERSE, CANVAS, CHANGE_VALUE, CHANGED, CHECK_SUBWINDOW, CLICKED, CLOSE_REQUEST, COMMIT, COMPUTE_SIZE, CONFIGURE_EVENT, COPY_CLIPBOARD, COPY_CLIPBOARD_INVERSE, CREATE_MENU_PROXY, CUT_CLIPBOARD, CUT_CLIPBOARD_INVERSE, data, DAY_SELECTED, DAY_SELECTED_DOUBLE_CLICK, DECELERATE, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_FROM_CURSOR, DELETE_FROM_CURSOR_INVERSE, DELETE_RANGE, DELETE_TEXT, DIRECTION_CHANGED, DISABLED, display, DISPOSE_SENT, DISPOSED, DPI_CHANGED, DRAG_DETECT, DRAW, ENTER, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPAND_COLLAPSE_CURSOR_ROW, EXPOSE_EVENT, EXPOSE_EVENT_INVERSE, FOCUS, FOCUS_IN, FOCUS_IN_EVENT, FOCUS_OUT, FOCUS_OUT_EVENT, FONT, FOREGROUND, FOREIGN_HANDLE, gdkSeatGrabPrepareFunc, GESTURE_PRESSED, GESTURE_RELEASED, GRAB_FOCUS, handle, HANDLE, HAS_AUTO_DIRECTION, HIDDEN, HIDE, ICON_RELEASE, IM_UPDATE, INPUT, INSERT_TEXT, IS_ACTIVE, KEY_CHECK_SUBWINDOW, KEY_GTK_CSS, KEY_PRESS_EVENT, KEY_PRESSED, KEY_RELEASE_EVENT, KEY_RELEASED, KEYED_DATA, LAST_SIGNAL, LAYOUT_CHANGED, LAYOUT_CHILD, LAYOUT_NEEDED, LEAVE, LEAVE_NOTIFY_EVENT, MAP, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MONTH_CHANGED, MOTION, MOTION_INVERSE, MOTION_NOTIFY_EVENT, MOTION_NOTIFY_EVENT_INVERSE, MOVE_CURSOR, MOVE_CURSOR_INVERSE, MOVE_FOCUS, MOVED, NOTIFY_DEFAULT_HEIGHT, NOTIFY_DEFAULT_WIDTH, NOTIFY_MAXIMIZED, NOTIFY_STATE, OBSCURED, OUTPUT, PARENT_BACKGROUND, PASTE_CLIPBOARD, PASTE_CLIPBOARD_INVERSE, POPPED_UP, POPULATE_POPUP, POPUP_MENU, PREEDIT_CHANGED, REALIZE, RELEASED, RESIZED, ROW_ACTIVATED, ROW_DELETED, ROW_HAS_CHILD_TOGGLED, ROW_INSERTED, SCROLL, SCROLL_BEGIN, SCROLL_CHILD, SCROLL_END, SCROLL_EVENT, SELECT, SELECTION_DONE, SHOW, SHOW_HELP, SIZE_ALLOCATE, SIZE_ALLOCATE_GTK4, SKIN_NEEDED, START_INTERACTIVE_SEARCH, state, STATUS_ICON_POPUP_MENU, style, STYLE_UPDATED, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TEXT_BUFFER_INSERT_TEXT, THEME_BACKGROUND, TOGGLED, UNMAP, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, WINDOW_STATE_EVENT, ZERO_HEIGHT, ZERO_WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of this class given its parent, and sets the style for the instance so that the instance will be a popup menu on the given parent's shell.Menu(Decorations parent, int style) Constructs a new instance of this class given its parent (which must be aDecorations) and a style value describing its behavior and appearance.Constructs a new instance of this class given its parent (which must be aMenu) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent.Constructs a new instance of this class given its parent (which must be aMenuItem) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent menu. -
Method Summary
Modifier and TypeMethodDescription(package private) void_setOrientation(int orientation) (package private) void_setVisible(boolean visible) (package private) booleanBug 532074: setLocation method is limited on Wayland since Wayland has no global coordinates and we cannot use gdk_popup_at_rect if GdkWindow of getShell is not mapped.(package private) voidaddAccelerators(long accelGroup) voidaddHelpListener(HelpListener listener) Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListenerinterface.voidaddMenuListener(MenuListener listener) Adds the listener to the collection of listeners who will be notified when menus are hidden or shown, by sending it one of the messages defined in theMenuListenerinterface.(package private) voidadjustParentWindowWayland(long eventPtr) Lack of absolute coordinates make Wayland event windows inaccurate.(package private) static Control(package private) static Menu(package private) static MenuItem(package private) static intcheckStyle(int style) (package private) voidcreateHandle(int index) (package private) voidcreateWidget(int index) (package private) voidOverridden to fix memory leak on GTK3, see bug 573983(package private) voidfixMenus(Decorations newParent) Returns the default menu item or null if none has been previously set.booleanReturnstrueif the receiver is enabled, andfalseotherwise.getItem(int index) Returns the item at the given, zero-relative index in the receiver.intReturns the number of items contained in the receiver.MenuItem[]getItems()Returns a (possibly empty) array ofMenuItems which are the items in the receiver.(package private) StringintReturns the orientation of the receiver, which will be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.Returns the receiver's parent, which must be aDecorations.Returns the receiver's parent item, which must be aMenuItemor null when the receiver is a root.Returns the receiver's parent item, which must be aMenuor null when the receiver is a root.getShell()Returns the receiver's shell.booleanReturnstrueif the receiver is visible, andfalseotherwise.(package private) longgtk_hide(long widget) (package private) longgtk_menu_popped_up(long widget, long flipped_rect, long final_rect, long flipped_x, long flipped_y) GTK3.22+ has API which allows clients of GTK to connect a menu to the "popped-up" signal.(package private) longgtk_show(long widget) (package private) longgtk3_show_help(long widget, long helpType) (package private) voidintSearches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item.booleanReturnstrueif the receiver is enabled and all of the receiver's ancestors are enabled, andfalseotherwise.booleanReturnstrueif the receiver is visible and all of the receiver's ancestors are visible andfalseotherwise.(package private) voidreleaseChildren(boolean destroy) (package private) void(package private) void(package private) voidremoveAccelerators(long accelGroup) voidremoveHelpListener(HelpListener listener) Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.voidremoveMenuListener(MenuListener listener) Removes the listener from the collection of listeners who will be notified when the menu events are generated for the control.(package private) voidreskinChildren(int flags) (package private) booleansendHelpEvent(long helpType) voidsetDefaultItem(MenuItem item) Sets the default menu item to the argument or removes the default emphasis when the argument isnull.voidsetEnabled(boolean enabled) Enables the receiver if the argument istrue, and disables it otherwise.voidsetLocation(int x, int y) Sets the location of the receiver, which must be a popup, to the point specified by the arguments which are relative to the display.voidsetLocation(Point location) Sets the location of the receiver, which must be a popup, to the point specified by the argument which is relative to the display.(package private) voidsetOrientation(boolean create) voidsetOrientation(int orientation) Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.voidsetVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.(package private) voidverifyMenuPosition(int itemCount) Feature in GTK3 on X11: context menus in SWT are populated dynamically, sometimes asynchronously outside of SWT (i.e.Methods inherited from class Widget
_addListener, addDisposeListener, addListener, addTypedListener, cellDataProc, checkBits, checkOpen, checkOrientation, checkParent, checkSubclass, checkWidget, convertPangoFontDescriptionToCss, cssHandle, deregister, dispose, dpiChanged, enterMotionProc, error, filterProc, filters, fixMnemonic, fixMnemonic, fixMnemonic, focusProc, fontHeight, gdk_event_free, gdk_event_get_state, gdk_event_get_surface_or_window, gdk_pointer_grab, gdk_pointer_ungrab, gdk_surface_get_size, gdk_window_get_size, GdkSeatGrabPrepareFunc, gesturePressReleaseProc, getData, getData, getDisplay, getListeners, getName, getStyle, getTypedListeners, gtk_activate, gtk_adjustment_get, gtk_box_new, gtk_box_pack_end, gtk_box_set_child_packing, gtk_button_press_event, gtk_button_release_event, gtk_cell_renderer_get_preferred_size, gtk_change_value, gtk_changed, gtk_clicked, gtk_close_request, gtk_commit, gtk_configure_event, gtk_container_get_border_width_or_margin, gtk_container_set_border_width, gtk_create_menu_proxy, gtk_day_selected, gtk_day_selected_double_click, gtk_delete_event, gtk_delete_range, gtk_delete_text, gtk_draw, gtk_enter_notify_event, gtk_expand_collapse_cursor_row, gtk_focus, gtk_focus_in_event, gtk_focus_out_event, gtk_gesture_press_event, gtk_gesture_release_event, gtk_grab_focus, gtk_icon_release, gtk_input, gtk_insert_text, gtk_leave_notify_event, gtk_map, gtk_map_event, gtk_mnemonic_activate, gtk_month_changed, gtk_motion_notify_event, gtk_move_focus, gtk_output, gtk_populate_popup, gtk_preedit_changed, gtk_realize, gtk_row_activated, gtk_row_has_child_toggled, gtk_scroll_child, gtk_scroll_event, gtk_select, gtk_selection_done, gtk_size_allocate, gtk_start_interactive_search, gtk_status_icon_popup_menu, gtk_style_updated, gtk_switch_page, gtk_test_collapse_row, gtk_test_expand_row, gtk_text_buffer_insert_text, gtk_timer, gtk_toggled, gtk_tree_view_column_cell_get_position, gtk_unmap, gtk_unmap_event, gtk_unrealize, gtk_value_changed, gtk_widget_get_preferred_size, gtk_widget_get_surface, gtk_widget_get_window, gtk_widget_hide, gtk_widget_show, gtk_widget_size_allocate, gtk_window_state_event, gtk3_event_after, gtk3_key_press_event, gtk3_key_release_event, gtk3_popup_menu, gtk4_draw, gtk4_enter_event, gtk4_focus_enter_event, gtk4_focus_leave_event, gtk4_focus_window_event, gtk4_key_press_event, gtk4_key_release_event, gtk4_leave_event, gtk4_motion_event, gtk4_scroll_event, hooks, hoverProc, isActive, isAutoDirection, isDisposed, isListening, isValidSubclass, isValidThread, keyPressReleaseProc, leaveProc, mnemonicHit, mnemonicMatch, notifyCreationTracker, notifyDisposalTracker, notifyListeners, notifyProc, notifyState, paintSurface, paintWindow, postEvent, postEvent, register, release, releaseHandle, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, rendererGetPreferredWidthProc, rendererRenderProc, rendererSnapshotProc, reskin, reskinWidget, scrollProc, sendEvent, sendEvent, sendEvent, sendEvent, sendIMKeyEvent, sendKeyEvent, sendSelectionEvent, sendSelectionEvent, setButtonState, setData, setData, setFontDescription, setInputState, setKeyState, setLocationState, setTabGroupFocus, setTabItemFocus, setToolTipText, shellMapProc, sizeAllocateProc, sizeRequestProc, snapshotToDraw, timerProc, topHandle, toString, translateTraversal, windowActiveProc, windowProc, windowProc, windowProc, windowProc, windowProc
-
Field Details
-
x
int x -
y
int y -
hasLocation
boolean hasLocation -
cascade
MenuItem cascade -
selectedItem
MenuItem selectedItem -
parent
Decorations parent -
imageList
ImageList imageList -
poppedUpCount
int poppedUpCount -
modelHandle
long modelHandleGTK4 only fields -
actionGroup
long actionGroupGTK4 only fields -
shortcutController
long shortcutControllerGTK4 only fields -
sections
LinkedList<Menu.Section> sections -
items
LinkedList<MenuItem> items
-
-
Constructor Details
-
Menu
Constructs a new instance of this class given its parent, and sets the style for the instance so that the instance will be a popup menu on the given parent's shell.After constructing a menu, it can be set into its parent using
parent.setMenu(menu). In this case, the parent may be any control in the same widget tree as the parent.- Parameters:
parent- a control which will be the parent of the new instance (cannot be null)- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
-
Menu
Constructs a new instance of this class given its parent (which must be aDecorations) and a style value describing its behavior and appearance.The style value is either one of the style constants defined in class
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.After constructing a menu or menuBar, it can be set into its parent using
parent.setMenu(menu)orparent.setMenuBar(menuBar).- Parameters:
parent- a decorations control which will be the parent of the new instance (cannot be null)style- the style of menu to construct- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
-
Menu
Constructs a new instance of this class given its parent (which must be aMenu) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent.After constructing a drop-down menu, it can be set into its parentMenu using
parentMenu.setMenu(menu).- Parameters:
parentMenu- a menu which will be the parent of the new instance (cannot be null)- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
-
Menu
Constructs a new instance of this class given its parent (which must be aMenuItem) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent menu.After constructing a drop-down menu, it can be set into its parentItem using
parentItem.setMenu(menu).- Parameters:
parentItem- a menu item which will be the parent of the new instance (cannot be null)- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
-
-
Method Details
-
checkNull
-
checkNull
-
checkNull
-
checkStyle
static int checkStyle(int style) -
ableToSetLocation
boolean ableToSetLocation()Bug 532074: setLocation method is limited on Wayland since Wayland has no global coordinates and we cannot use gdk_popup_at_rect if GdkWindow of getShell is not mapped. In this case, we can only pop the menu at the pointer. This happens for example when Problems view is a fast view on Eclipse start, the drop down menu takes PartRenderingEngine's limbo shell (see PartRenderingEngine#safeCreateGui) which is off the screen.- Returns:
- true iff the location of menu is set and can be used successfully
-
_setVisible
void _setVisible(boolean visible) -
addAccelerators
void addAccelerators(long accelGroup) -
addMenuListener
Adds the listener to the collection of listeners who will be notified when menus are hidden or shown, by sending it one of the messages defined in theMenuListenerinterface.- Parameters:
listener- the listener which should be notified- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
addHelpListener
Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListenerinterface.- Parameters:
listener- the listener which should be notified- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
createHandle
void createHandle(int index) - Overrides:
createHandlein classWidget
-
createWidget
void createWidget(int index) - Overrides:
createWidgetin classWidget
-
fixMenus
-
getDefaultItem
Returns the default menu item or null if none has been previously set.- Returns:
- the default menu item.
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getEnabled
public boolean getEnabled()Returnstrueif the receiver is enabled, andfalseotherwise. A disabled menu is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
getItem
Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.- Parameters:
index- the index of the item to return- Returns:
- the item at the given index
- Throws:
IllegalArgumentException-- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItemCount
public int getItemCount()Returns the number of items contained in the receiver.- Returns:
- the number of items
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItems
Returns a (possibly empty) array ofMenuItems which are the items in the receiver.Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
- Returns:
- the items in the receiver
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getNameText
String getNameText()- Overrides:
getNameTextin classWidget
-
getOrientation
public int getOrientation()Returns the orientation of the receiver, which will be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Returns:
- the orientation style
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- Since:
- 3.7
-
getParent
Returns the receiver's parent, which must be aDecorations.- Returns:
- the receiver's parent
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getParentItem
Returns the receiver's parent item, which must be aMenuItemor null when the receiver is a root.- Returns:
- the receiver's parent item
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getParentMenu
Returns the receiver's parent item, which must be aMenuor null when the receiver is a root.- Returns:
- the receiver's parent item
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getShell
Returns the receiver's shell. For all controls other than shells, this simply returns the control's nearest ancestor shell. Shells return themselves, even if they are children of other shells. Returns null if receiver or its ancestor is the application menubar.- Returns:
- the receiver's shell or null
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
getVisible
public boolean getVisible()Returnstrueif the receiver is visible, andfalseotherwise.If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.
- Returns:
- the receiver's visibility state
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
gtk_hide
-
gtk_show
-
gtk3_show_help
long gtk3_show_help(long widget, long helpType) - Overrides:
gtk3_show_helpin classWidget
-
hookEvents
void hookEvents()- Overrides:
hookEventsin classWidget
-
indexOf
Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. If no item is found, returns -1.- Parameters:
item- the search item- Returns:
- the index of the item
- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the item is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
isEnabled
public boolean isEnabled()Returnstrueif the receiver is enabled and all of the receiver's ancestors are enabled, andfalseotherwise. A disabled menu is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
isVisible
public boolean isVisible()Returnstrueif the receiver is visible and all of the receiver's ancestors are visible andfalseotherwise.- Returns:
- the receiver's visibility state
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
releaseChildren
void releaseChildren(boolean destroy) - Overrides:
releaseChildrenin classWidget
-
releaseParent
void releaseParent()- Overrides:
releaseParentin classWidget
-
releaseWidget
void releaseWidget()- Overrides:
releaseWidgetin classWidget
-
destroyWidget
void destroyWidget()Overridden to fix memory leak on GTK3, see bug 573983- Overrides:
destroyWidgetin classWidget
-
removeMenuListener
Removes the listener from the collection of listeners who will be notified when the menu events are generated for the control.- Parameters:
listener- the listener which should no longer be notified- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
removeAccelerators
void removeAccelerators(long accelGroup) -
removeHelpListener
Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.- Parameters:
listener- the listener which should no longer be notified- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
-
reskinChildren
void reskinChildren(int flags) - Overrides:
reskinChildrenin classWidget
-
sendHelpEvent
boolean sendHelpEvent(long helpType) -
setDefaultItem
Sets the default menu item to the argument or removes the default emphasis when the argument isnull.- Parameters:
item- the default menu item or null- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the menu item has been disposed
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setEnabled
public void setEnabled(boolean enabled) Enables the receiver if the argument istrue, and disables it otherwise. A disabled menu is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Parameters:
enabled- the new enabled state- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setLocation
public void setLocation(int x, int y) Sets the location of the receiver, which must be a popup, to the point specified by the arguments which are relative to the display.Note that this is different from most widgets where the location of the widget is relative to the parent.
Also note that the actual location of the menu is dependent on platform specific behavior. For example: on Linux with Wayland this operation is a hint due to lack of global coordinates.
- Parameters:
x- the new x coordinate for the receivery- the new y coordinate for the receiver- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setLocation
Sets the location of the receiver, which must be a popup, to the point specified by the argument which is relative to the display.Note that this is different from most widgets where the location of the widget is relative to the parent.
Note that the platform window manager ultimately has control over the location of popup menus.
- Parameters:
location- the new location for the receiver- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the point is null
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- Since:
- 2.1
-
setOrientation
public void setOrientation(int orientation) Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Parameters:
orientation- new orientation style- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- Since:
- 3.7
-
_setOrientation
void _setOrientation(int orientation) -
setOrientation
void setOrientation(boolean create) - Overrides:
setOrientationin classWidget
-
adjustParentWindowWayland
void adjustParentWindowWayland(long eventPtr) Lack of absolute coordinates make Wayland event windows inaccurate. Currently the best approach is to the use the GdkWindow of the mouse pointer. See bug 530059 and 532074.- Parameters:
eventPtr- a pointer to the GdkEvent
-
verifyMenuPosition
void verifyMenuPosition(int itemCount) Feature in GTK3 on X11: context menus in SWT are populated dynamically, sometimes asynchronously outside of SWT (i.e. in Platform UI). This means that items are added and removed just before the menu is shown. This method of changing the menu content can sometimes cause sizing issues internally in GTK, specifically with the height of the toplevel GdkWindow.The fix is to cache the number of items popped up previously, and if the number of items in the current menu (to be popped up) is different, then:
- get the preferred height of the menu
- set the toplevel GdkWindow to that height
- Parameters:
itemCount- the current number of items in the menu, just before it's about to be shown/popped-up
-
setVisible
public void setVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed.
- Parameters:
visible- the new visibility state- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-