widelands
widelands copied to clipboard
Keyboard shortcuts for add-ons
Mirrored from Codeberg
Created on Wed Sep 04 15:26:31 CEST 2024 by Benedikt Straub (Nordfriese)
Type of change New feature
Issue(s) closed Scripts can now define custom keyboard shortcuts, replace existing ones, and attach Lua scripts to keyboard shortcuts.
How it works See also the updated docs.
Use the new function set_keyboard_shortcut()
in wl.ui.MapView
or wl.ui.MainMenu
to attach a Lua script to an existing shortcut.
When adding entries to dropdowns and listselects, you can now also specify the hotkey to display for the entry.
Add-ons can register custom keyboard shortcuts in a new file addon-name.wad/shortcuts.lua
. This is available to all add-on types, since it makes sense at least for plugins and scripts, and quite possibly more types. These files are always parsed, even if the add-on is disabled, so that they still show up in the options menu.
Possible regressions Handling of keyboard shortcuts.
Screenshots
Additional context
The updated notify-speed
add-on (v1.1.1) uses the new functionality. The regression test suite also has some checks for it.