Package: gtk

Class gtk-accel-label

Superclasses

gtk-label, gtk-misc, gtk-widget, gtk-buildable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

accel-closure
The accel-closure property of type g-closure (Read / Write)
The closure to be monitored for accelerator changes.
accel-widget
The accel-widget property of type gtk-widget (Read / Write)
The widget to be monitored for accelerator changes.

Details

The gtk-accel-label widget is a subclass of the gtk-label class that also displays an accelerator key on the right of the label text, e.g. "Ctrl+Q". It is commonly used in menus to show the keyboard short-cuts for commands.



The accelerator key to display is not set explicitly. Instead, the accel label displays the accelerators which have been added to a particular widget. This widget is set by calling the gtk-accel-label-accel-widget function.

For example, a gtk-menu-item widget may have an accelerator added to emit the "activate" signal when the "Ctrl+Q" key combination is pressed. A gtk-accel-label widget is created and added to the gtk-menu-item widget, and the gtk-accel-label-accel-widget function is called with the gtk-menu-item widget as the second argument. The accel label will now display "Ctrl+Q" after its label.

Note that creating a gtk-menu-item widget with the gtk-menu-item-new-with-label function, or one of the similar functions for the gtk-check-menu-item and gtk-radio-menu-item widgets, automatically adds a gtk-accel-label widget to the gtk-menu-item widget and calls the gtk-accel-label-accel-widget function to set it up for you.

A accel label will only display accelerators which have the :visible value of the gtk-accel-flags flags set. A accel label can display multiple accelerators and even signal names, though it is almost always used to display just one accelerator key.

Example

Creating a menu item with an accelerator key.
(let (...
      (item-file-quit (make-instance 'gtk-menu-item
                                     :label "Quit")))
  ;; Add an accelerator to the QUIT menu item
  (let ((group (gtk-accel-group-new)))
    (gtk-window-add-accel-group window group)
    (gtk-widget-add-accelerator item-file-quit
                                "activate"
                                group
                                (gdk-keyval-from-name "q")
                                :control-mask
                                :visible)
    ...)
...)    
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-12-22