parent
a52ff707fe
commit
43c16a1643
After Width: | Height: | Size: 227 B |
@ -0,0 +1,40 @@
|
|||||||
|
PopupMenuButton < UIButton
|
||||||
|
font: verdana-11px-antialised
|
||||||
|
background-color: alpha
|
||||||
|
color: #aaaaaa
|
||||||
|
height: 18
|
||||||
|
margin-left: 3
|
||||||
|
margin-right: 3
|
||||||
|
|
||||||
|
image:
|
||||||
|
source: /core_styles/images/empty_rect.png
|
||||||
|
repeated: true
|
||||||
|
|
||||||
|
$hover:
|
||||||
|
color: #ffffff
|
||||||
|
background-color: #ffffff44
|
||||||
|
|
||||||
|
$disabled:
|
||||||
|
color: #555555
|
||||||
|
|
||||||
|
PopupMenuFirstButton < PopupMenuButton
|
||||||
|
margin-top: 3
|
||||||
|
|
||||||
|
PopupMenuLastButton < PopupMenuButton
|
||||||
|
margin-bottom: 3
|
||||||
|
|
||||||
|
PopupMenuSeparator < UIWidget
|
||||||
|
margin-left: 2
|
||||||
|
margin-right: 2
|
||||||
|
image:
|
||||||
|
source: /core_styles/images/menubox.png
|
||||||
|
repeated: true
|
||||||
|
coords: 3 0 26 3
|
||||||
|
height: 3
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
PopupMenu < UIPopupMenu
|
||||||
|
width: 100
|
||||||
|
border-image:
|
||||||
|
source: /core_styles/images/menubox.png
|
||||||
|
border: 3
|
@ -0,0 +1,34 @@
|
|||||||
|
-- extends UIWidget
|
||||||
|
UIPopupMenu = extends(UIWidget)
|
||||||
|
|
||||||
|
-- public functions
|
||||||
|
function UIPopupMenu.create()
|
||||||
|
local menu = UIPopupMenu.internalCreate()
|
||||||
|
local layout = UIVerticalLayout.create(menu)
|
||||||
|
layout:setFitParent(true)
|
||||||
|
menu:setLayout(layout)
|
||||||
|
return menu
|
||||||
|
end
|
||||||
|
|
||||||
|
function UIPopupMenu.display(otui, pos)
|
||||||
|
local menu = UI.display(otui, {x = pos.x, y = pos.y})
|
||||||
|
return menu
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hooked events
|
||||||
|
local function onWidgetStyleApply(widget, style)
|
||||||
|
if style and style.popupmenu then
|
||||||
|
widget.popupmenu = style.popupmenu
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onWidgetMousePress(widget, mousePos, mouseButton)
|
||||||
|
if widget.popupmenu and mouseButton == MouseRightButton then
|
||||||
|
UIPopupMenu.display(widget.popupmenu, mousePos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
|
||||||
|
onMousePress = onWidgetMousePress })
|
@ -1,10 +1,5 @@
|
|||||||
Panel
|
PopupMenu
|
||||||
layout: verticalBox
|
PopupMenuFirstButton
|
||||||
size: 64 48
|
text: Look
|
||||||
|
PopupMenuLastButton
|
||||||
MenuButton
|
text: Use
|
||||||
text: Foo
|
|
||||||
|
|
||||||
MenuButton
|
|
||||||
text: Quit
|
|
||||||
@onClick: exit()
|
|
Loading…
Reference in new issue