parent
48c22756f5
commit
ca702109d6
@ -1,6 +1,6 @@
|
|||||||
Item < UIItem
|
Item < UIItem
|
||||||
size: 34 34
|
size: 34 34
|
||||||
item margin: 1
|
item margin: 1
|
||||||
border-image:
|
border-image:
|
||||||
source: /core_styles/images/panel_flat.png
|
source: /core_styles/images/panel_flat.png
|
||||||
border: 4
|
border: 4
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
MenuButton < UIButton
|
|
||||||
color: white
|
|
||||||
size: 40 18
|
|
||||||
align: center
|
|
||||||
border-image:
|
|
||||||
source: /core_styles/images/menu.png
|
|
||||||
size: 64 24
|
|
||||||
|
|
||||||
state.hover:
|
|
||||||
border-image:
|
|
||||||
source: /core_styles/images/menu.png
|
|
||||||
offset: 0 24
|
|
||||||
size: 64 24
|
|
||||||
color: black
|
|
||||||
|
|
||||||
TopMenuButton < MenuButton
|
|
||||||
onMousePress: |
|
|
||||||
function(self, mousePos, mouseButton)
|
|
||||||
local popupMenu = UI.loadAndDisplay(self:getStyle()['popup menu'])
|
|
||||||
if popupMenu then
|
|
||||||
popupMenu:moveTo({ x = self:getX(), y = self:getY() + self:getHeight()})
|
|
||||||
popupMenu.onMouseRelease = function(self) self:destroy() end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
TopMenuButton
|
|
||||||
text: File
|
|
||||||
position: 80 0
|
|
||||||
popup menu: /playground/filemenu.otui
|
|
@ -1,10 +1,24 @@
|
|||||||
-- place any code for testing purposes here
|
-- 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
|
end
|
||||||
|
|
||||||
local function init()
|
local function init()
|
||||||
UI.loadAndDisplay('/playground/menubar.otui')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
addEvent(init)
|
addEvent(init)
|
Loading…
Reference in new issue