mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
auto resize menu width
This commit is contained in:
@@ -27,7 +27,7 @@ function UIComboBox:addOption(text, data)
|
||||
end
|
||||
|
||||
function UIComboBox:onMousePress(mousePos, mouseButton)
|
||||
local menu = createWidget('PopupMenu', self)
|
||||
local menu = createWidget(self:getStyleName() .. 'PopupMenu', self)
|
||||
for i,v in ipairs(self.options) do
|
||||
menu:addOption(v.text, function() self:setCurrentOption(v.text) end)
|
||||
end
|
||||
|
@@ -23,6 +23,8 @@ function UIPopupMenu:addOption(optionName, optionCallback)
|
||||
self:destroy()
|
||||
end
|
||||
optionWidget:setText(optionName)
|
||||
local width = optionWidget:getTextSize().width + optionWidget:getMarginLeft() + optionWidget:getMarginRight() + 6
|
||||
self:setWidth(math.max(self:getWidth(), width))
|
||||
end
|
||||
|
||||
function UIPopupMenu:addSeparator()
|
||||
|
Reference in New Issue
Block a user