detect clicks on part of pin that sticks up

develop
Myk Taylor 2023-01-09 12:52:26 -08:00
parent 2234328a91
commit fecc733192
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 38 additions and 16 deletions

@ -721,6 +721,13 @@ 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
if keys._MOUSE_L_DOWN then
df.global.enabler.mouse_lbut_down = 0
end
if keys._MOUSE_R_DOWN then
df.global.enabler.mouse_rbut_down = 0
end
return return
end end
@ -729,7 +736,8 @@ function ZScreen:onInput(keys)
return return
end end
if not self.locked and (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) then if (self:isMouseOver() or not self.locked)
and (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) then
self:dismiss() self:dismiss()
-- ensure underlying DF screens don't also react to the click -- ensure underlying DF screens don't also react to the click
df.global.enabler.mouse_rbut_down = 0 df.global.enabler.mouse_rbut_down = 0

@ -272,10 +272,30 @@ local function Panel_on_double_click(self)
Panel_update_frame(self, frame, true) Panel_update_frame(self, frame, true)
end end
local function panel_is_on_pin(self)
local frame_rect = self.frame_rect
local x,y = dscreen.getMousePos()
return (x == frame_rect.x2-2 or x == frame_rect.x2-1)
and (y == frame_rect.y1-1 or y == frame_rect.y1)
end
local function panel_is_pinnable(self)
return self.lockable and self.parent_view and self.parent_view.toggleLocked
end
function Panel:getMouseFramePos()
local x,y = Panel.super.getMouseFramePos(self)
if x then return x, y end
if panel_is_pinnable(self) and panel_is_on_pin(self) then
local frame_rect = self.frame_rect
return frame_rect.width - 3, 0
end
end
function Panel:onInput(keys) function Panel:onInput(keys)
if self.kbd_get_pos then if self.kbd_get_pos then
if keys.SELECT or keys.LEAVESCREEN then if keys.SELECT or keys.LEAVESCREEN or keys._MOUSE_R_DOWN then
Panel_end_drag(self, keys.LEAVESCREEN and self.saved_frame or nil, Panel_end_drag(self, not keys.SELECT and self.saved_frame or nil,
not not keys.SELECT) not not keys.SELECT)
return true return true
end end
@ -300,7 +320,13 @@ function Panel:onInput(keys)
end end
return true return true
end end
if self:inputToSubviews(keys) then if panel_is_pinnable(self) and keys._MOUSE_L_DOWN then
if panel_is_on_pin(self) then
self.parent_view:toggleLocked()
return true
end
end
if Panel.super.onInput(self, keys) then
return true return true
end end
if not keys._MOUSE_L_DOWN then return end if not keys._MOUSE_L_DOWN then return end
@ -498,18 +524,6 @@ Window.ATTRS {
lockable = true, lockable = true,
} }
function Window:onInput(keys)
if keys._MOUSE_L_DOWN and self.parent_view and self.parent_view.toggleLocked then
local x,y = dscreen.getMousePos()
local frame_rect = self.frame_rect
if (x == frame_rect.x2-2 or x == frame_rect.x2-1)
and (y == frame_rect.y1-1 or y == frame_rect.y1) then
self.parent_view:toggleLocked()
end
end
return Window.super.onInput(self, keys)
end
------------------- -------------------
-- ResizingPanel -- -- ResizingPanel --
------------------- -------------------