Catch mouse clicks if `contextmenu` is open
Also disallow re-opening the `contextmenu` if it's already visible.
This commit is contained in:
parent
4934e741b3
commit
3950406750
|
@ -171,20 +171,22 @@ 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 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
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
if button == "right" then
|
||||
caught = self:show(px, py)
|
||||
end
|
||||
end
|
||||
return caught
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue