mirror of
https://github.com/edubart/otclient.git
synced 2025-12-15 21:29:46 +01:00
item menu example
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
-- place any code for testing purposes here
|
||||
|
||||
function displayMenuPopup(file, parent)
|
||||
function UIItem.onMouseRelease(self, mousePos, mouseButton)
|
||||
if mouseButton ~= MouseRightButton then return end
|
||||
local top = self:getY()
|
||||
local bottom = self:getY() + self:getHeight()
|
||||
local left = self:getX()
|
||||
local right = self:getX() + self:getWidth()
|
||||
if not (mousePos.y >= top and mousePos.y <= bottom and mousePos.x >= left and mousePos.x <= right) then return end
|
||||
|
||||
local menuFile = self:getStyle()['popup menu']
|
||||
if not menuFile then return end
|
||||
|
||||
local popupMenu = UI.loadAndDisplay(menuFile)
|
||||
if not popupMenu then return end
|
||||
|
||||
popupMenu:moveTo(mousePos)
|
||||
popupMenu.onMouseRelease = function(self) self:destroy() end
|
||||
end
|
||||
|
||||
local function init()
|
||||
UI.loadAndDisplay('/playground/menubar.otui')
|
||||
end
|
||||
|
||||
addEvent(init)
|
||||
Reference in New Issue
Block a user