Development Team/Almanac/sugar.graphics.toolbutton: Difference between revisions
Garycmartin (talk | contribs) change from alt to Ctrl as that is the primary modifier |
|||
| Line 44: | Line 44: | ||
=== How do I add a keyboard shortcut to my tool button? === | === How do I add a keyboard shortcut to my tool button? === | ||
In the example below, we add the Ctrl-b short cut to our custom button. | |||
#Add keyboard shortcut for customButton | #Add keyboard shortcut for customButton | ||
customButton.props.accelerator = '< | customButton.props.accelerator = '<ctrl>b' | ||
If you want to enable translators to override the shortcut, use the gettext syntax so that an entry in the POT file is generated (See [[Development_Team/Almanac/Internationalization]] for details): | If you want to enable translators to override the shortcut, use the gettext syntax so that an entry in the POT file is generated (See [[Development_Team/Almanac/Internationalization]] for details): | ||
customButton.props.accelerator = _('< | customButton.props.accelerator = _('<ctrl>b') | ||
If you want to use symbols in you shortcuts, you'll need to refer to the X11 keysymdefs (/usr/include/X11/keysymdef.h), e.g., to use a "+" as a shortcut, you'd refer to <code>#define XK_plus 0x002b /* U+002B PLUS SIGN */</code> and use the string after the <code>XK_</code>: | If you want to use symbols in you shortcuts, you'll need to refer to the X11 keysymdefs (/usr/include/X11/keysymdef.h), e.g., to use a "+" as a shortcut, you'd refer to <code>#define XK_plus 0x002b /* U+002B PLUS SIGN */</code> and use the string after the <code>XK_</code>: | ||
customButton.props.accelerator = _('< | customButton.props.accelerator = _('<ctrl>plus') | ||