mirror of
https://github.com/labwc/labwc.git
synced 2026-06-17 14:33:30 -04:00
menu: implement menu accelerators
Menu accelerators are one-letter mnemonics to quickly select/exec items from the current menu. For each menu item, the accelerator is defined as the first character of the item label, converted to lowercase. A different accelerator can be explicitly defined in menu.xml with the special '_' character before the target letter. - Add a field `accelerator` to the `menuitem` struct - Implement `menu_item_select_by_accelerator()` Example: The accelerator for an item with the label "e_macs" is 'm'.
This commit is contained in:
parent
07a0a4e59b
commit
3632c6703a
4 changed files with 190 additions and 8 deletions
|
|
@ -444,15 +444,24 @@ handle_menu_keys(struct keysyms *syms)
|
|||
break;
|
||||
case XKB_KEY_Return:
|
||||
case XKB_KEY_KP_Enter:
|
||||
menu_call_selected_actions();
|
||||
if (!menu_call_selected_actions()) {
|
||||
menu_submenu_enter();
|
||||
};
|
||||
break;
|
||||
case XKB_KEY_Escape:
|
||||
menu_close_root();
|
||||
cursor_update_focus();
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
default: {
|
||||
uint32_t accelerator = xkb_keysym_to_utf32(syms->syms[i]);
|
||||
if (accelerator == 0) {
|
||||
continue;
|
||||
}
|
||||
if (menu_item_select_by_accelerator(accelerator)) {
|
||||
menu_call_selected_actions();
|
||||
}
|
||||
break;
|
||||
}}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue