Merge pull request #3414 from myk002/myk_scroll_to_focus

scroll mouse wheel to focus window under cursor
develop
Myk 2023-05-25 17:18:52 -07:00 committed by GitHub
commit 2efeead96e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 10 deletions

@ -62,6 +62,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `overlay`: added links to the quickstart guide and the control panel on the DF title screen
- Window behavior: non-resizable windows now allow dragging by their frame edges by default
- `gui/autodump`: fort-mode keybinding: Ctrl-H
- Window behavior: if you have multiple DFHack tool windows open, scrolling the mouse wheel while over an unfocused window will focus it and raise it to the top
## Documentation

@ -4240,11 +4240,11 @@ input skips all unfocused ZScreens under that ZScreen and is passed directly to
the first non-ZScreen viewscreen. There are class attributes that can be set to
control what kind of unhandled input is passed to the lower layers.
If multiple ZScreens are visible and the player left or right clicks on a
visible element of a non-focused ZScreen, that ZScreen will be given focus. This
allows multiple DFHack GUI tools to be usable at the same time. If the mouse is
clicked away from the ZScreen widgets, that ZScreen loses focus. If no ZScreen
has focus, all input is passed directly through to the first underlying
If multiple ZScreens are visible and the player scrolls or left/right clicks on
a visible element of a non-focused ZScreen, that ZScreen will be given focus.
This allows multiple DFHack GUI tools to be usable at the same time. If the
mouse is clicked away from the ZScreen widgets, that ZScreen loses focus. If no
ZScreen has focus, all input is passed directly through to the first underlying
non-ZScreen viewscreen.
For a ZScreen with keyboard focus, if :kbd:`Esc` or the right mouse button is

@ -787,7 +787,10 @@ end
function ZScreen:onInput(keys)
local has_mouse = self:isMouseOver()
if not self:hasFocus() then
if (keys._MOUSE_L_DOWN or keys._MOUSE_R_DOWN) and has_mouse then
if has_mouse and
(keys._MOUSE_L_DOWN or keys._MOUSE_R_DOWN or
keys.CONTEXT_SCROLL_UP or keys.CONTEXT_SCROLL_DOWN or
keys.CONTEXT_SCROLL_PAGEUP or keys.CONTEXT_SCROLL_PAGEDOWN) then
self:raise()
else
self:sendInputToParent(keys)
@ -818,10 +821,15 @@ function ZScreen:onInput(keys)
end
local passit = self.pass_pause and keys.D_PAUSE
if not passit and self.pass_mouse_clicks then
for key in pairs(MOUSE_KEYS) do
if keys[key] then
passit = true
break
if keys.CONTEXT_SCROLL_UP or keys.CONTEXT_SCROLL_DOWN or
keys.CONTEXT_SCROLL_PAGEUP or keys.CONTEXT_SCROLL_PAGEDOWN then
passit = true
else
for key in pairs(MOUSE_KEYS) do
if keys[key] then
passit = true
break
end
end
end
end