From 395040675064d830de1bedf8ffaf6f3dcbfa1df8 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 27 Apr 2022 17:55:46 +0200 Subject: [PATCH] Catch mouse clicks if `contextmenu` is open Also disallow re-opening the `contextmenu` if it's already visible. --- data/core/contextmenu.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/data/core/contextmenu.lua b/data/core/contextmenu.lua index 1c9839e7..b1a69d6d 100644 --- a/data/core/contextmenu.lua +++ b/data/core/contextmenu.lua @@ -171,19 +171,21 @@ function ContextMenu:call_selected_item() end function ContextMenu:on_mouse_pressed(button, px, py, clicks) - local selected = self:get_item_selected() local caught = false - self:hide() - if button == "left" then - if selected then - self:on_selected(selected) - caught = true + if self.show_context_menu then + if button == "left" then + local selected = self:get_item_selected() + if selected then + self:on_selected(selected) + end + end + self:hide() + caught = true + else + if button == "right" then + caught = self:show(px, py) end - end - - if button == "right" then - caught = self:show(px, py) end return caught end