mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
add menu example in playerground module
This commit is contained in:
BIN
modules/core_styles/images/menu.png
Normal file
BIN
modules/core_styles/images/menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 262 B |
10
modules/playground/filemenu.otui
Normal file
10
modules/playground/filemenu.otui
Normal file
@@ -0,0 +1,10 @@
|
||||
Panel
|
||||
layout: verticalBox
|
||||
size: 64 48
|
||||
|
||||
MenuButton
|
||||
text: New
|
||||
|
||||
MenuButton
|
||||
text: Quit
|
||||
onClick: exit()
|
29
modules/playground/menubar.otui
Normal file
29
modules/playground/menubar.otui
Normal file
@@ -0,0 +1,29 @@
|
||||
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 +1,10 @@
|
||||
-- place any code for testing purposes here
|
||||
-- place any code for testing purposes here
|
||||
|
||||
function displayMenuPopup(file, parent)
|
||||
end
|
||||
|
||||
local function init()
|
||||
UI.loadAndDisplay('/playground/menubar.otui')
|
||||
end
|
||||
|
||||
addEvent(init)
|
Reference in New Issue
Block a user