mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 04:53:27 +02:00
Reimplement text edit scrolling in C++
* And update some corelib APIs
This commit is contained in:
@@ -3,6 +3,7 @@ UIComboBox = extends(UIWidget)
|
||||
|
||||
function UIComboBox.create()
|
||||
local combobox = UIComboBox.internalCreate()
|
||||
combobox:setFocusable(false)
|
||||
combobox.options = {}
|
||||
combobox.currentIndex = -1
|
||||
combobox.mouseScroll = true
|
||||
@@ -15,6 +16,15 @@ function UIComboBox:clearOptions()
|
||||
self:clearText()
|
||||
end
|
||||
|
||||
function UIComboBox:getOption(text)
|
||||
if not self.options then return nil end
|
||||
for i,v in ipairs(self.options) do
|
||||
if v.text == text then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIComboBox:setCurrentOption(text)
|
||||
if not self.options then return end
|
||||
for i,v in ipairs(self.options) do
|
||||
@@ -27,6 +37,18 @@ function UIComboBox:setCurrentOption(text)
|
||||
end
|
||||
end
|
||||
|
||||
function UIComboBox:setCurrentOptionByData(data)
|
||||
if not self.options then return end
|
||||
for i,v in ipairs(self.options) do
|
||||
if v.data == data and self.currentIndex ~= i then
|
||||
self.currentIndex = i
|
||||
self:setText(v.text)
|
||||
self:onOptionChange(v.text, v.data)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIComboBox:setCurrentIndex(index)
|
||||
if index >= 1 and index <= #self.options then
|
||||
local v = self.options[index]
|
||||
|
Reference in New Issue
Block a user