Merge pull request #2847 from robob27/hotkeylabel-enhancements

Add setLabel/setOnActivate to HotkeyLabel
develop
Myk 2023-02-08 12:38:35 -08:00 committed by GitHub
commit d74f00f7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

@ -60,6 +60,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Lua ## Lua
- `overlay`: overlay widgets can now specify focus paths for the viewscreens they attach to so they only appear in specific contexts. see `overlay-dev-guide` for details. - `overlay`: overlay widgets can now specify focus paths for the viewscreens they attach to so they only appear in specific contexts. see `overlay-dev-guide` for details.
- ``widgets.CycleHotkeyLabel``: Added ``key_back`` optional parameter to cycle backwards. - ``widgets.CycleHotkeyLabel``: Added ``key_back`` optional parameter to cycle backwards.
- ``widgets.HotkeyLabel``: Added ``setLabel`` method to allow easily updating the label text without mangling the keyboard shortcut.
- ``widgets.HotkeyLabel``: Added ``setOnActivate`` method to allow easily updating the ``on_activate`` callback.
- ``widgets.FilteredList``: Added ``case_sensitive`` optional paramter to determine if filtering is case sensitive. - ``widgets.FilteredList``: Added ``case_sensitive`` optional paramter to determine if filtering is case sensitive.
## Removed ## Removed

@ -4808,6 +4808,16 @@ It has the following attributes:
:on_activate: If specified, it is the callback that will be called whenever :on_activate: If specified, it is the callback that will be called whenever
the hotkey is pressed or the label is clicked. the hotkey is pressed or the label is clicked.
The HotkeyLabel widget implements the following methods:
* ``hotkeylabel:setLabel(label)``
Updates the label without altering the hotkey text.
* ``hotkeylabel:setOnActivate(on_activate)``
Updates the on_activate callback.
CycleHotkeyLabel class CycleHotkeyLabel class
---------------------- ----------------------

@ -1419,6 +1419,20 @@ HotkeyLabel.ATTRS{
} }
function HotkeyLabel:init() function HotkeyLabel:init()
self:initializeLabel()
end
function HotkeyLabel:setOnActivate(on_activate)
self.on_activate = on_activate
self:initializeLabel()
end
function HotkeyLabel:setLabel(label)
self.label = label
self:initializeLabel()
end
function HotkeyLabel:initializeLabel()
self:setText{{key=self.key, key_sep=self.key_sep, text=self.label, self:setText{{key=self.key, key_sep=self.key_sep, text=self.label,
on_activate=self.on_activate}} on_activate=self.on_activate}}
end end