mirror of
https://github.com/edubart/otclient.git
synced 2025-10-13 19:14:56 +02:00
improvment in connect
This commit is contained in:
@@ -20,6 +20,15 @@ end
|
||||
|
||||
function connect(object, signalsAndSlots, pushFront)
|
||||
for signal,slot in pairs(signalsAndSlots) do
|
||||
if not object[signal] then
|
||||
local mt = getmetatable(object)
|
||||
if mt then
|
||||
object[signal] = function(...)
|
||||
return signalcall(mt[signal], ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not object[signal] then
|
||||
object[signal] = slot
|
||||
elseif type(object[signal]) == 'function' then
|
||||
@@ -140,7 +149,7 @@ function signalcall(param, ...)
|
||||
return param(...)
|
||||
elseif type(param) == 'table' then
|
||||
for k,v in pairs(param) do
|
||||
if param(...) then
|
||||
if v(...) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@@ -44,7 +44,7 @@ function ToolTip.init()
|
||||
toolTipLabel = createWidget('Label', rootWidget)
|
||||
toolTipLabel:setId('toolTip')
|
||||
toolTipLabel:setBackgroundColor('#111111bb')
|
||||
connect(toolTipLabel, { onMouseMove = moveToolTip })
|
||||
toolTipLabel.onMouseMove = moveToolTip
|
||||
|
||||
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
|
||||
onHoverChange = onWidgetHoverChange})
|
||||
|
@@ -30,9 +30,9 @@ end
|
||||
function UIPopupMenu:addOption(optionName, optionCallback)
|
||||
local optionWidget = createWidget(self:getStyleName() .. 'Button', self)
|
||||
local lastOptionWidget = self:getLastChild()
|
||||
optionWidget.onClick = function()
|
||||
optionWidget.onClick = function(self)
|
||||
optionCallback()
|
||||
self:destroy()
|
||||
self:getParent():destroy()
|
||||
end
|
||||
optionWidget:setText(optionName)
|
||||
local width = optionWidget:getTextSize().width + optionWidget:getMarginLeft() + optionWidget:getMarginRight() + 6
|
||||
|
@@ -36,7 +36,11 @@ function UIMap:onDrop(widget, mousePos)
|
||||
spinbox:setCurrentIndex(count)
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function() g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
okButton.onClick = function()
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex())
|
||||
okButton:getParent():destroy()
|
||||
widget.currentDragThing = nil
|
||||
end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
else
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), 1)
|
||||
|
Reference in New Issue
Block a user