prevent mouse clicks from bleeding through when a window is dismissed

develop
Myk Taylor 2023-02-13 17:35:02 -08:00
parent c1f62f4985
commit bc76fd02e2
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
4 changed files with 24 additions and 15 deletions

@ -45,6 +45,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements ## Misc Improvements
- DFHack tool windows that capture mouse clicks (and therefore prevent you from clicking on the "pause" button) now unconditionally pause the game when they open (but you can still unpause with the keyboard if you want to). Examples of this behavior: `gui/quickfort`, `gui/blueprint`, `gui/liquids` - DFHack tool windows that capture mouse clicks (and therefore prevent you from clicking on the "pause" button) now unconditionally pause the game when they open (but you can still unpause with the keyboard if you want to). Examples of this behavior: `gui/quickfort`, `gui/blueprint`, `gui/liquids`
- `showmood`: now shows the number of items needed for cloth and bars in addition to the technically correct but always confusing "total dimension" (150 per bar or 10,000 per cloth) - `showmood`: now shows the number of items needed for cloth and bars in addition to the technically correct but always confusing "total dimension" (150 per bar or 10,000 per cloth)
-@ Stopped mouse clicks from affecting the map when a click on a DFHack screen dismisses the window
## Documentation ## Documentation

@ -697,6 +697,19 @@ DEFAULT_INITIAL_PAUSE = true
local zscreen_inhibit_mouse_l = false local zscreen_inhibit_mouse_l = false
-- ensure underlying DF screens don't also react to handled clicks
function markMouseClicksHandled(keys)
if keys._MOUSE_L_DOWN then
-- note we can't clear mouse_lbut here. otherwise we break dragging,
df.global.enabler.mouse_lbut_down = 0
zscreen_inhibit_mouse_l = true
end
if keys._MOUSE_R_DOWN then
df.global.enabler.mouse_rbut_down = 0
df.global.enabler.mouse_rbut = 0
end
end
ZScreen = defclass(ZScreen, Screen) ZScreen = defclass(ZScreen, Screen)
ZScreen.ATTRS{ ZScreen.ATTRS{
defocusable=true, defocusable=true,
@ -782,16 +795,7 @@ function ZScreen:onInput(keys)
end end
if ZScreen.super.onInput(self, keys) then if ZScreen.super.onInput(self, keys) then
-- ensure underlying DF screens don't also react to handled clicks markMouseClicksHandled(keys)
if keys._MOUSE_L_DOWN then
-- note we can't clear mouse_lbut here. otherwise we break dragging,
df.global.enabler.mouse_lbut_down = 0
zscreen_inhibit_mouse_l = true
end
if keys._MOUSE_R_DOWN then
df.global.enabler.mouse_rbut_down = 0
df.global.enabler.mouse_rbut = 0
end
return return
end end
@ -801,9 +805,7 @@ function ZScreen:onInput(keys)
return return
elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then
self:dismiss() self:dismiss()
-- ensure underlying DF screens don't also react to the rclick markMouseClicksHandled(keys)
df.global.enabler.mouse_rbut_down = 0
df.global.enabler.mouse_rbut = 0
return return
else else
if zscreen_inhibit_mouse_l then if zscreen_inhibit_mouse_l then

@ -262,12 +262,14 @@ function Menu:onInput(keys)
local x = list:getMousePos() local x = list:getMousePos()
if x == 0 then -- clicked on icon if x == 0 then -- clicked on icon
self:onSubmit2(list:getSelected()) self:onSubmit2(list:getSelected())
df.global.enabler.mouse_lbut = 0
return true return true
end end
if not self:getMouseFramePos() and not self.hotspot:getMousePos() then if not self:getMouseFramePos() and not self.hotspot:getMousePos() then
self.parent_view:dismiss() self.parent_view:dismiss()
return true return true
end end
df.global.enabler.mouse_lbut = 0
end end
self:inputToSubviews(keys) self:inputToSubviews(keys)
return true -- we're modal return true -- we're modal

@ -488,8 +488,12 @@ local function _feed_viewscreen_widgets(vs_name, keys)
end end
function feed_viewscreen_widgets(vs_name, keys) function feed_viewscreen_widgets(vs_name, keys)
return _feed_viewscreen_widgets(vs_name, keys) or if not _feed_viewscreen_widgets(vs_name, keys) and
_feed_viewscreen_widgets('all', keys) not _feed_viewscreen_widgets('all', keys) then
return false
end
gui.markMouseClicksHandled(keys)
return true
end end
local function _render_viewscreen_widgets(vs_name, dc) local function _render_viewscreen_widgets(vs_name, dc)