add defocusable attribute to ZScreen

develop
Myk Taylor 2023-02-01 08:46:32 -08:00
parent 0ff7ad0cc4
commit 88860f21ec
No known key found for this signature in database
3 changed files with 9 additions and 1 deletions

@ -68,6 +68,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `helpdb`: changed from auto-refreshing every 60 seconds to only refreshing on explicit call to ``helpdb.refresh()``. docs very rarely change during a play session, and the automatic database refreshes were slowing down the startup of `gui/launcher` - `helpdb`: changed from auto-refreshing every 60 seconds to only refreshing on explicit call to ``helpdb.refresh()``. docs very rarely change during a play session, and the automatic database refreshes were slowing down the startup of `gui/launcher`
- ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom - ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom
- ``dfhack.units.getCitizens()``: gets a list of citizens - ``dfhack.units.getCitizens()``: gets a list of citizens
- ``gui.ZScreen``: new attribute: ``defocusable`` for controlling whether a window loses keyboard focus when the map is clicked
## Removed ## Removed
- `autohauler`: no plans to port to v50, as it just doesn't make sense with the new work detail system - `autohauler`: no plans to port to v50, as it just doesn't make sense with the new work detail system

@ -4187,6 +4187,12 @@ ZScreen provides the following functions:
ZScreen subclasses can set the following attributes: ZScreen subclasses can set the following attributes:
* ``defocusable`` (default: ``true``)
Whether the ZScreen loses keyboard focus when the player clicks on an area
of the screen other than the tool window. If the player clicks on a different
ZScreen window, focus still transfers to that other ZScreen.
* ``initial_pause`` (default: ``DEFAULT_INITIAL_PAUSE``) * ``initial_pause`` (default: ``DEFAULT_INITIAL_PAUSE``)
Whether to pause the game when the ZScreen is shown. ``DEFAULT_INITIAL_PAUSE`` Whether to pause the game when the ZScreen is shown. ``DEFAULT_INITIAL_PAUSE``

@ -699,6 +699,7 @@ local zscreen_inhibit_mouse_l = false
ZScreen = defclass(ZScreen, Screen) ZScreen = defclass(ZScreen, Screen)
ZScreen.ATTRS{ ZScreen.ATTRS{
defocusable=true,
initial_pause=DEFAULT_NIL, initial_pause=DEFAULT_NIL,
force_pause=false, force_pause=false,
pass_pause=true, pass_pause=true,
@ -793,7 +794,7 @@ function ZScreen:onInput(keys)
end end
if self.pass_mouse_clicks and keys._MOUSE_L_DOWN and not has_mouse then if self.pass_mouse_clicks and keys._MOUSE_L_DOWN and not has_mouse then
self.defocused = true self.defocused = self.defocusable
self:sendInputToParent(keys) self:sendInputToParent(keys)
return return
elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then