mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
new lua function for creating widgets: createWidget
This commit is contained in:
@@ -10,7 +10,7 @@ function MessageBox.create(title, text, flags)
|
||||
setmetatable(box, MessageBox)
|
||||
|
||||
-- create messagebox window
|
||||
local window = UI.display('messagebox.otui', { locked = true })
|
||||
local window = displayUI('messagebox.otui', { locked = true })
|
||||
window:setTitle(title)
|
||||
|
||||
local label = window:getChildById('messageBoxLabel')
|
||||
|
@@ -20,7 +20,7 @@ end
|
||||
function ToolTip.display(text)
|
||||
if text then
|
||||
ToolTip.hide()
|
||||
currentToolTip = UI.display('tooltip.otui')
|
||||
currentToolTip = displayUI('tooltip.otui')
|
||||
currentToolTip.onMouseMove = moveToolTip
|
||||
local label = currentToolTip:getChildById('toolTipText')
|
||||
label:setText(text)
|
||||
|
@@ -7,12 +7,11 @@ function UIPopupMenu.create()
|
||||
local layout = UIVerticalLayout.create(menu)
|
||||
layout:setFitParent(true)
|
||||
menu:setLayout(layout)
|
||||
menu:setStyle('PopupMenu')
|
||||
return menu
|
||||
end
|
||||
|
||||
function UIPopupMenu.display(menu, pos)
|
||||
UI.display(menu, {x = pos.x, y = pos.y})
|
||||
displayUI(menu, {x = pos.x, y = pos.y})
|
||||
menu:bindRectToParent()
|
||||
menu:grabMouse()
|
||||
menu:grabKeyboard()
|
||||
@@ -20,21 +19,17 @@ function UIPopupMenu.display(menu, pos)
|
||||
end
|
||||
|
||||
function UIPopupMenu.addOption(menu, optionName, optionCallback)
|
||||
local optionWidget = UIButton.create()
|
||||
local optionWidget = createWidget(menu.buttonStyle, menu)
|
||||
local lastOptionWidget = menu:getLastChild()
|
||||
optionWidget.onClick = function()
|
||||
optionCallback()
|
||||
menu:destroy()
|
||||
end
|
||||
optionWidget:setText(optionName)
|
||||
optionWidget:setStyle('PopupMenuButton')
|
||||
menu:addChild(optionWidget)
|
||||
end
|
||||
|
||||
function UIPopupMenu.addSeparator(menu)
|
||||
local separatorWidget = UIWidget.create()
|
||||
separatorWidget:setStyle('PopupMenuSeparator')
|
||||
menu:addChild(separator)
|
||||
local separatorWidget = createWidget(menu.separatorStyle, separator)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
@@ -54,3 +49,12 @@ function UIPopupMenu.onKeyPress(menu, keyCode, keyText, keyboardModifiers)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function UIPopupMenu.onStyleApply(menu, style)
|
||||
if style['button-style'] then
|
||||
menu.buttonStyle = style['button-style']
|
||||
end
|
||||
if style['separator-style'] then
|
||||
menu.separatorStyle = style['separator-style']
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user