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,19 +171,21 @@ function ContextMenu:call_selected_item()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ContextMenu:on_mouse_pressed(button, px, py, clicks)
|
function ContextMenu:on_mouse_pressed(button, px, py, clicks)
|
||||||
local selected = self:get_item_selected()
|
|
||||||
local caught = false
|
local caught = false
|
||||||
|
|
||||||
self:hide()
|
if self.show_context_menu then
|
||||||
if button == "left" then
|
if button == "left" then
|
||||||
if selected then
|
local selected = self:get_item_selected()
|
||||||
self:on_selected(selected)
|
if selected then
|
||||||
caught = true
|
self:on_selected(selected)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:hide()
|
||||||
|
caught = true
|
||||||
|
else
|
||||||
|
if button == "right" then
|
||||||
|
caught = self:show(px, py)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if button == "right" then
|
|
||||||
caught = self:show(px, py)
|
|
||||||
end
|
end
|
||||||
return caught
|
return caught
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue