Package: gtk
Class gtk-menu
Superclassesgtk-menu-shell, gtk-container, gtk-widget, gtk-buildable, g-object, common-lisp:standard-object, common-lisp:t Documented SubclassesDirect SlotsThe accel-group property of type gtk-accel-group (Read / Write) The accelerator group holding accelerators for the menu. The accel-path property of type :string (Read / Write) An accel path used to conveniently construct accel paths of child items. Default value: nil The active property of type :int (Read / Write) The index of the currently selected menu item, or -1 if no menu item is selected. Allowed values: >= -1 Default value: -1 The anchor-hints property of type gdk-anchor-hints (Read / Write / Construct) Positioning hints for aligning the menu relative to a rectangle. These hints determine how the menu should be positioned in the case that the menu would fall off-screen if placed in its ideal position. Since 3.22 Default value: '(:flip-x :flip-y :slide-x :slide-y :resize-x :resize-y) The attach-widget property of type gtk-widget (Read / Write) The widget the menu is attached to. Setting this property attaches the menu without a GtkMenuDetachFunc callback function. If you need to use a detacher, use the gtk-menu-attach-to-widget function directly. The menu-type-hint property of type gdk-window-type-hint (Read / Write / Construct) The gdk-window-type-hint value to use for the gdk-window object of the menu. Since 3.22 Default value: :popup-menu The monitor property of type :int (Read / Write) The monitor the menu will be popped up on. Allowed values: >= -1 Default value: -1 The rect-anchor-dx property of type :int (Read / Write / Construct) Horizontal offset to apply to the menu, i.e. the rectangle or widget anchor. Since 3.22 Default value: 0 The rect-anchor-dy property of type :int (Read / Write / Construct) Vertical offset to apply to the menu, i.e. the rectangle or widget anchor. Since 3.22 Default value: 0 The reserve-toggle-size property of type :boolean (Read / Write) A boolean that indicates whether the menu reserves space for toggles and icons, regardless of their actual presence. This property should only be changed from its default value for special purposes such as tabular menus. Regular menus that are connected to a menu bar or context menus should reserve toggle space for consistency. Default value: true The tearoff-state property of type :boolean (Read / Write) A boolean that indicates whether the menu is torn-off. Warning: The tearoff-state property has been deprecated since version 3.10 and should not be used in newly written code. Default value: false The tearoff-title property of type :string (Read / Write) A title that may be displayed by the window manager when this menu is torn-off. Warning: The tearoff-title property has been deprecated since version 3.10 and should not be used in newly written code. Default value: nil Details A gtk-menu widget is a gtk-menu-shell widget that implements a drop down menu consisting of a list of gtk-menu-item widgets
which can be navigated and activated by the user to perform application
functions. A gtk-menu widget is most commonly dropped down by activating a gtk-menu-item widget in a gtk-menu-bar widget or popped up by activating a gtk-menu-item widget in another gtk-menu widget. A gtk-menu widget can also be popped up by activating a gtk-combo-box widget. Other composite widgets such as the gtk-notebook widget can pop up a gtk-menu widget as well. Applications can display a gtk-menu widget as a popup menu by calling the gtk-menu-popup-at-pointer function. The example below shows how an application can pop up a menu when a mouse button is pressed. Example(defun example-menu-popup (&optional application) (within-main-loop (let ((window (make-instance 'gtk-window :type :toplevel :application application :default-width 300 :default-height 180 :title "Example Popup Menu")) (button (gtk-button-new-with-label "Click me"))) ;; Create pop-up menu for button (let ((popup (make-instance 'gtk-menu)) (bigitem (gtk-menu-item-new-with-label "Larger")) (smallitem (gtk-menu-item-new-with-label "Smaller"))) (gtk-menu-shell-append popup bigitem) (gtk-menu-shell-append popup smallitem) (gtk-widget-show-all popup) ;; Signal handler to pop up the menu (g-signal-connect button "button-press-event" (lambda (widget event) (declare (ignore widget)) (gtk-menu-popup-at-pointer popup event) t))) (g-signal-connect window "destroy" (lambda (widget) (declare (ignore widget)) (leave-gtk-main))) (gtk-container-add window button) (gtk-widget-show-all window)))) CSS nodesmenu ├── arrow.top ├── <child> ┊ ├── <child> ╰── arrow.bottomThe main CSS node of the gtk-menu implemenation has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes. Child Property Details
Style Property Details
Signal DetailsThe "move-scroll" signallambda (menu scrolltype) :action
The "popped-up" signallambda (menu flipped final xflipped yflipped) :run-firstEmitted when the position of the menu is finalized after being popped up using the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, or gtk-menu-popup-at-pointer functions. The menu might be flipped over the anchor rectangle in order to keep it on-screen, in which case the xflipped and yflipped arguments will be set to true accordingly. The flipped argument is the ideal position of the menu after any possible flipping, but before any possible sliding. The final argument is flipped, but possibly translated in the case that flipping is still ineffective in keeping menu on-screen. ![]() The blue menu is the ideal position of the menu, the green menu is flipped, and the red menu is final. See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, and the anchor-hints, rect-anchor-dx, rect-anchor-dy, and menu-type-hint properties. Since 3.22
| Slot Access FunctionsInherited Slot Access FunctionsSee also |
*2021-11-14