1.45 <AdwShortcutLabel>

Class: <AdwShortcutLabel>

It derives from <GtkWidget>.

A widget that displays a keyboard shortcut.

The shown shortcut can be set using the ShortcutLabel:accelerator property.

Optionally, if no shortcut is set, <AdwShortcutLabel> will display a placeholder set with the ShortcutLabel:disabled-text property.

The following types of shortcuts can be displayed:

  • Multiple alternative shortcuts, separated with spaces, e.g. <Shift>A Home:
  • A range of shortcuts, separated with ..., e.g. <Alt>1...9:
  • Multiple keys pressed at once, separated with &, e.g. Control_L&Control_R:
  • Multiple shortcuts or keys, pressed sequentially, separated with +, e.g. <Control>C+<Control>X:

::: note <, > and & need to be escaped as &lt;, &gt; and &amp; when used in UI files.

CSS nodes

<AdwShortcutLabel> has a single CSS node with name shortcut-label. The individual keycap labels each have the .keycap style class, while the labels separating them have the .dimmed style class.

Accessibility

<AdwShortcutLabel> uses the Gtk.AccessibleRole.label role.

See also: ShortcutsDialog.

Properties

Property: shortcut-label:accelerator self

The displayed accelerator.

Its value is a string, or #f.

Set it with (set! (shortcut-label:accelerator self) value).

Property: shortcut-label:disabled-text self

The text displayed when no accelerator is set.

Its value is a string, or #f.

Set it with (set! (shortcut-label:disabled-text self) value).

Procedures

Method: shortcut-label:get-accelerator self ⇒ %return
Method: get-accelerator self ⇒ %return

Gets the accelerator displayed by self.

self

Passed: a <AdwShortcutLabel>.

a shortcut label

%return

Returned: a string.

the displayed accelerator

Method: shortcut-label:get-disabled-text self ⇒ %return
Method: get-disabled-text self ⇒ %return

Gets the text displayed by self when no accelerator is set.

self

Passed: a <AdwShortcutLabel>.

a shortcut label

%return

Returned: a string.

the text displayed when no accelerator is set

Procedure: shortcut-label:new accelerator ⇒ %return

Creates a new <AdwShortcutLabel> showing accelerator.

accelerator

Passed: a string.

the accelerator to show

%return

Returned: a <GtkWidget>.

the newly created <AdwShortcutLabel>

Method: shortcut-label:set-accelerator self accelerator
Method: set-accelerator self accelerator

Sets the accelerator to be displayed by self.

self

Passed: a <AdwShortcutLabel>.

a shortcut label

accelerator

Passed: a string.

the accelerator to be displayed

Method: shortcut-label:set-disabled-text self disabled-text
Method: set-disabled-text self disabled-text

Sets the text to be displayed by self when no accelerator is set.

self

Passed: a <AdwShortcutLabel>.

a shortcut label

disabled-text

Passed: a string.

the text displayed when no accelerator is set