diff --git a/devel/inspect-screen.lua b/devel/inspect-screen.lua index 3510cf0468..36d42564be 100644 --- a/devel/inspect-screen.lua +++ b/devel/inspect-screen.lua @@ -325,7 +325,7 @@ function Inspect:onInput(keys) if Inspect.super.onInput(self, keys) then return true end - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then self.subviews.freeze:cycle() return true end diff --git a/exportlegends.lua b/exportlegends.lua index 69633a6320..22373fd7a5 100644 --- a/exportlegends.lua +++ b/exportlegends.lua @@ -1070,7 +1070,7 @@ function LegendsOverlay:init() end function LegendsOverlay:onInput(keys) - if keys._MOUSE_L_DOWN and progress_percent < 0 and + if keys._MOUSE_L and progress_percent < 0 and self.subviews.button_mask:getMousePos() and self.subviews.do_export:getOptionValue() then @@ -1102,7 +1102,7 @@ end function DoneMaskOverlay:onInput(keys) if progress_percent >= 0 then - if keys.LEAVESCREEN or (keys._MOUSE_L_DOWN and self:getMousePos()) then + if keys.LEAVESCREEN or (keys._MOUSE_L and self:getMousePos()) then return true end end diff --git a/gui/autochop.lua b/gui/autochop.lua index 12122875c8..5fc6a858db 100644 --- a/gui/autochop.lua +++ b/gui/autochop.lua @@ -101,7 +101,7 @@ function BurrowSettings:commit() end function BurrowSettings:onInput(keys) - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then self:hide() return true end diff --git a/gui/autodump.lua b/gui/autodump.lua index a0ab71f686..bb81432b0b 100644 --- a/gui/autodump.lua +++ b/gui/autodump.lua @@ -267,11 +267,11 @@ end function Autodump:onInput(keys) if Autodump.super.onInput(self, keys) then return true end - if keys._MOUSE_R_DOWN and self.mark then + if keys._MOUSE_R and self.mark then self.mark = nil self:updateLayout() return true - elseif keys._MOUSE_L_DOWN then + elseif keys._MOUSE_L then if self:getMouseFramePos() then return true end local pos = dfhack.gui.getMousePos() if not pos then diff --git a/gui/blueprint.lua b/gui/blueprint.lua index 0335e1b19f..f05d4bada5 100644 --- a/gui/blueprint.lua +++ b/gui/blueprint.lua @@ -459,7 +459,7 @@ end function Blueprint:onInput(keys) if Blueprint.super.onInput(self, keys) then return true end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then if self:is_setting_start_pos() then self.subviews.startpos.option_idx = 1 self.saved_cursor = nil @@ -474,7 +474,7 @@ function Blueprint:onInput(keys) end local pos = nil - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then pos = dfhack.gui.getMousePos() if pos then guidm.setCursorPos(pos) diff --git a/gui/control-panel.lua b/gui/control-panel.lua index 24689c0c6b..bd7a49ee48 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -250,7 +250,7 @@ end function ConfigPanel:onInput(keys) local handled = ConfigPanel.super.onInput(self, keys) - if keys._MOUSE_L_DOWN then + if keys._MOUSE_L then local list = self.subviews.list.list local idx = list:getIdxUnderMouse() if idx then @@ -603,7 +603,7 @@ function IntegerInputDialog:onInput(keys) if keys.SELECT then self:hide(self.subviews.input_edit.text) return true - elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + elseif keys.LEAVESCREEN or keys._MOUSE_R then self:hide() return true end @@ -638,7 +638,7 @@ end function Preferences:onInput(keys) -- call grandparent's onInput since we don't want ConfigPanel's processing local handled = Preferences.super.super.onInput(self, keys) - if keys._MOUSE_L_DOWN then + if keys._MOUSE_L then local list = self.subviews.list.list local idx = list:getIdxUnderMouse() if idx then @@ -787,7 +787,7 @@ end function RepeatAutostart:onInput(keys) -- call grandparent's onInput since we don't want ConfigPanel's processing local handled = RepeatAutostart.super.super.onInput(self, keys) - if keys._MOUSE_L_DOWN then + if keys._MOUSE_L then local list = self.subviews.list.list local idx = list:getIdxUnderMouse() if idx then diff --git a/gui/design.lua b/gui/design.lua index 66ef48ddb3..a0a215d4ad 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -1386,7 +1386,7 @@ function Design:onInput(keys) -- return -- end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then -- Close help window if open if view.help_window.visible then self:dismiss_help() return true end @@ -1438,7 +1438,7 @@ function Design:onInput(keys) local pos = nil - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then pos = getMousePoint() if not pos then return true end guidm.setCursorPos(dfhack.gui.getMousePos()) @@ -1446,7 +1446,7 @@ function Design:onInput(keys) pos = Point(guidm.getCursorPos()) end - if keys._MOUSE_L_DOWN and pos then + if keys._MOUSE_L and pos then -- TODO Refactor this a bit if self.shape.max_points and #self.marks == self.shape.max_points and self.placing_mark.active then self.marks[self.placing_mark.index] = pos diff --git a/gui/gm-editor.lua b/gui/gm-editor.lua index 0814d84d83..380e9cdd3c 100644 --- a/gui/gm-editor.lua +++ b/gui/gm-editor.lua @@ -514,7 +514,7 @@ end function GmEditorUi:onInput(keys) if GmEditorUi.super.onInput(self, keys) then return true end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then if dfhack.internal.getModifiers().shift then return false end diff --git a/gui/gm-unit.lua b/gui/gm-unit.lua index f37ec6f546..b83ed49cf9 100644 --- a/gui/gm-unit.lua +++ b/gui/gm-unit.lua @@ -147,7 +147,7 @@ end function Editor_Unit:onInput(keys) local pages = self.subviews.pages if pages:getSelected() == 1 or - (not keys.LEAVESCREEN and not keys._MOUSE_R_DOWN) then + (not keys.LEAVESCREEN and not keys._MOUSE_R) then return Editor_Unit.super.onInput(self, keys) end local page = pages:getSelectedPage() diff --git a/gui/liquids.lua b/gui/liquids.lua index 4eda71242a..f5d90483fb 100644 --- a/gui/liquids.lua +++ b/gui/liquids.lua @@ -210,7 +210,7 @@ function SpawnLiquid:onRenderFrame(dc, rect) local mouse_pos = dfhack.gui.getMousePos() if self.is_dragging then - if df.global.enabler.mouse_lbut == 0 then + if df.global.enabler.mouse_lbut_down == 0 then self.is_dragging = false elseif mouse_pos and not self:getMouseFramePos() then self:spawn(mouse_pos) @@ -228,7 +228,7 @@ end function SpawnLiquid:onInput(keys) if SpawnLiquid.super.onInput(self, keys) then return true end - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then local mouse_pos = dfhack.gui.getMousePos() if self.paint_mode == SpawnLiquidPaintMode.CLICK and mouse_pos then @@ -258,7 +258,7 @@ function SpawnLiquid:onInput(keys) end -- TODO: Holding the mouse down causes event spam. - if keys._MOUSE_L and not self:getMouseFramePos() then + if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then if self.paint_mode == SpawnLiquidPaintMode.DRAG then self.is_dragging = true return true diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index 3c2781a380..4be9fb338a 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -175,7 +175,7 @@ end function MassRemove:onInput(keys) if MassRemove.super.onInput(self, keys) then return true end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then if self.mark then self.mark = nil self:updateLayout() @@ -185,7 +185,7 @@ function MassRemove:onInput(keys) end local pos = nil - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then pos = dfhack.gui.getMousePos() end if not pos then return false end diff --git a/gui/masspit.lua b/gui/masspit.lua index 464701781d..f7d77176bb 100644 --- a/gui/masspit.lua +++ b/gui/masspit.lua @@ -186,7 +186,7 @@ end function Masspit:onInput(keys) if Masspit.super.onInput(self, keys) then return true end - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then if self.subviews.pages:getSelected() == 1 then local building = dfhack.buildings.findAtTile(dfhack.gui.getMousePos()) diff --git a/gui/overlay.lua b/gui/overlay.lua index 017c66738c..a0c5719495 100644 --- a/gui/overlay.lua +++ b/gui/overlay.lua @@ -57,7 +57,7 @@ DraggablePanel.ATTRS{ } function DraggablePanel:onInput(keys) - if keys._MOUSE_L_DOWN then + if keys._MOUSE_L then local rect = self.frame_rect local x,y = self:getMousePos(gui.ViewRect{rect=rect}) if x then @@ -281,7 +281,7 @@ function OverlayConfig:onInput(keys) return true end end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then self:dismiss() return true end diff --git a/gui/quickfort.lua b/gui/quickfort.lua index 13014a2c75..2d713c7b3e 100644 --- a/gui/quickfort.lua +++ b/gui/quickfort.lua @@ -52,7 +52,7 @@ end function BlueprintDetails:onInput(keys) if keys.CUSTOM_CTRL_D or keys.SELECT - or keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + or keys.LEAVESCREEN or keys._MOUSE_R then self:dismiss() end end @@ -211,7 +211,7 @@ function BlueprintDialog:onInput(keys) details:show() -- for testing self._details = details - elseif keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + elseif keys.LEAVESCREEN or keys._MOUSE_R then self:dismiss() if self.on_cancel then self.on_cancel() @@ -606,7 +606,7 @@ function Quickfort:onInput(keys) return true end - if keys._MOUSE_L_DOWN and not self:getMouseFramePos() then + if keys._MOUSE_L and not self:getMouseFramePos() then local pos = dfhack.gui.getMousePos() if pos then self:commit() diff --git a/gui/sandbox.lua b/gui/sandbox.lua index ff74ceb31a..b491e1b899 100644 --- a/gui/sandbox.lua +++ b/gui/sandbox.lua @@ -121,7 +121,7 @@ function Sandbox:init() key='CUSTOM_SHIFT_U', label="Spawn unit", on_activate=function() - df.global.enabler.mouse_lbut = 0 + df.global.enabler.mouse_lbut_down = 0 clear_arena_action() view:sendInputToParent{ARENA_CREATE_CREATURE=true} df.global.game.main_interface.arena_unit.editing_filter = true @@ -162,7 +162,7 @@ function Sandbox:init() key='CUSTOM_SHIFT_T', label="Spawn tree", on_activate=function() - df.global.enabler.mouse_lbut = 0 + df.global.enabler.mouse_lbut_down = 0 clear_arena_action() view:sendInputToParent{ARENA_CREATE_TREE=true} df.global.game.main_interface.arena_tree.editing_filter = true @@ -189,11 +189,11 @@ function Sandbox:init() end function Sandbox:onInput(keys) - if keys._MOUSE_R_DOWN and self:getMouseFramePos() then + if keys._MOUSE_R and self:getMouseFramePos() then clear_arena_action() return false end - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then if is_arena_action_in_progress() then clear_arena_action() return true @@ -204,7 +204,7 @@ function Sandbox:onInput(keys) if Sandbox.super.onInput(self, keys) then return true end - if keys._MOUSE_L then + if keys._MOUSE_L_DOWN then if self:getMouseFramePos() then return true end for _,mask_panel in ipairs(self.interface_masks) do if mask_panel:getMousePos() then return true end @@ -252,7 +252,7 @@ InterfaceMask.ATTRS{ } function InterfaceMask:onInput(keys) - return keys._MOUSE_L and self:getMousePos() + return keys._MOUSE_L_DOWN and self:getMousePos() end --------------------- diff --git a/gui/seedwatch.lua b/gui/seedwatch.lua index 30ae9dc8d0..612b42ee48 100644 --- a/gui/seedwatch.lua +++ b/gui/seedwatch.lua @@ -78,7 +78,7 @@ function SeedSettings:commit() end function SeedSettings:onInput(keys) - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then self:hide() return true end diff --git a/gui/unit-syndromes.lua b/gui/unit-syndromes.lua index 93a3476a7c..994f967c08 100644 --- a/gui/unit-syndromes.lua +++ b/gui/unit-syndromes.lua @@ -441,7 +441,7 @@ function UnitSyndromes:push_state() end function UnitSyndromes:onInput(keys) - if keys._MOUSE_R_DOWN then + if keys._MOUSE_R then self:previous_page() return true end diff --git a/hide-tutorials.lua b/hide-tutorials.lua index 6887a77df4..f31a6072f2 100644 --- a/hide-tutorials.lua +++ b/hide-tutorials.lua @@ -29,7 +29,7 @@ function skip_tutorial_prompt(scr) df.global.gps.mouse_y = 18 df.global.enabler.mouse_lbut = 1 df.global.enabler.mouse_lbut_down = 1 - gui.simulateInput(scr, '_MOUSE_L_DOWN') + gui.simulateInput(scr, '_MOUSE_L') end end diff --git a/internal/caravan/trade.lua b/internal/caravan/trade.lua index 47401f272a..9c8650eef3 100644 --- a/internal/caravan/trade.lua +++ b/internal/caravan/trade.lua @@ -525,7 +525,7 @@ end function TradeScreen:onInput(keys) if self.reset_pending then return false end local handled = TradeScreen.super.onInput(self, keys) - if keys._MOUSE_L_DOWN and not self.trade_window:getMouseFramePos() then + if keys._MOUSE_L and not self.trade_window:getMouseFramePos() then -- "trade" or "offer" buttons may have been clicked and we need to reset the cache self.reset_pending = true end @@ -780,7 +780,7 @@ end function TradeOverlay:onInput(keys) if TradeOverlay.super.onInput(self, keys) then return true end - if keys._MOUSE_L_DOWN then + if keys._MOUSE_L then if dfhack.internal.getModifiers().shift then handle_shift_click_on_render = true copyGoodflagState() @@ -819,7 +819,7 @@ end function TradeBannerOverlay:onInput(keys) if TradeBannerOverlay.super.onInput(self, keys) then return true end - if keys._MOUSE_R_DOWN or keys.LEAVESCREEN then + if keys._MOUSE_R or keys.LEAVESCREEN then if view then view:dismiss() end diff --git a/internal/gm-unit/editor_body.lua b/internal/gm-unit/editor_body.lua index 9c250d3828..b6e8935308 100644 --- a/internal/gm-unit/editor_body.lua +++ b/internal/gm-unit/editor_body.lua @@ -163,7 +163,7 @@ function Editor_Body_Modifier:init(args) end function Editor_Body_Modifier:onInput(keys) - if keys.LEAVESCREEN or keys._MOUSE_R_DOWN then + if keys.LEAVESCREEN or keys._MOUSE_R then self:setFocus(false) self.visible = false else diff --git a/test/gui/blueprint.lua b/test/gui/blueprint.lua index 55651719da..fcf45a932f 100644 --- a/test/gui/blueprint.lua +++ b/test/gui/blueprint.lua @@ -297,7 +297,7 @@ function test.set_with_mouse() mock.patch(dfhack.gui, 'getMousePos', mock.func(pos), function() local view = load_ui() - view:onInput({_MOUSE_L_DOWN=true}) + view:onInput({_MOUSE_L=true}) expect.table_eq(pos, view.mark, comment) send_keys('LEAVESCREEN') -- cancel selection send_keys('LEAVESCREEN') -- cancel out of UI