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 SlotsDetails 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