Merge pull request #2775 from myk002/myk_non_defocusable

add defocusable attribute to ZScreen
develop
Myk 2023-02-01 17:53:21 -08:00 committed by GitHub
commit a3f32e66ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

@ -72,6 +72,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
- ``Label``: token ``tile`` properties can now be either pens or numeric texture ids - ``Label``: token ``tile`` properties can now be either pens or numeric texture ids
## Removed ## Removed

@ -4193,6 +4193,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