contextmenu: adjust y positioning if less than zero (#1268)
* use clamp for both x and y coords
This commit is contained in:
@@ -83,12 +83,8 @@ function ContextMenu:show(x, y)
|
|||||||
local w, h = self.items.width, self.items.height
|
local w, h = self.items.width, self.items.height
|
||||||
|
|
||||||
-- by default the box is opened on the right and below
|
-- by default the box is opened on the right and below
|
||||||
if x + w >= core.root_view.size.x then
|
x = common.clamp(x, 0, core.root_view.size.x - w - style.padding.x)
|
||||||
x = x - w
|
y = common.clamp(y, 0, core.root_view.size.y - h)
|
||||||
end
|
|
||||||
if y + h >= core.root_view.size.y then
|
|
||||||
y = y - h
|
|
||||||
end
|
|
||||||
|
|
||||||
self.position.x, self.position.y = x, y
|
self.position.x, self.position.y = x, y
|
||||||
self.show_context_menu = true
|
self.show_context_menu = true
|
||||||
|
|||||||
Reference in New Issue
Block a user