add options style for UIComboBox, fix push values of otml nodes

master
Eduardo Bart 13 years ago
parent 186e3dc86b
commit e6cb3de637

@ -64,6 +64,7 @@ change win32 mouse cursor icon
[bart] make set of background/icon/image width alone work [bart] make set of background/icon/image width alone work
[bart] check for recursive anchors and print a error instead of crashing [bart] check for recursive anchors and print a error instead of crashing
[bart] make api to enable/disable capture of events to avoid massive event processing [bart] make api to enable/disable capture of events to avoid massive event processing
[bart] review style apply system
== Client modules == Client modules
[bart] make possible to reload modules [bart] make possible to reload modules

@ -55,8 +55,8 @@ local function onWidgetStyleApply(widget, styleName, styleNode)
end end
end end
connect(UIWidget, { onStyleApply = onWidgetStyleApply, --connect(UIWidget, { onStyleApply = onWidgetStyleApply,
onHoverChange = onWidgetHoverChange}) -- onHoverChange = onWidgetHoverChange})
-- UIWidget extensions -- UIWidget extensions
function UIWidget:setTooltip(text) function UIWidget:setTooltip(text)

@ -13,7 +13,7 @@ function UIComboBox:setCurrentOption(text)
if v.text == text and self.m_currentIndex ~= i then if v.text == text and self.m_currentIndex ~= i then
self.m_currentIndex = i self.m_currentIndex = i
self:setText(text) self:setText(text)
self:onOptionChange(text, data) self:onOptionChange(text, v.data)
return return
end end
end end
@ -38,6 +38,14 @@ function UIComboBox:onMousePress(mousePos, mouseButton)
return true return true
end end
function UIComboBox:onStyleApply(styleName, styleNode)
if styleNode.options then
for k,option in pairs(styleNode.options) do
self:addOption(option)
end
end
end
function UIComboBox:onOptionChange(optionText, optionData) function UIComboBox:onOptionChange(optionText, optionData)
-- nothing todo -- nothing todo
end end

@ -219,15 +219,18 @@ void push_otml_subnode_luavalue(const OTMLNodePtr& node)
} else if(node->hasChildren()) { } else if(node->hasChildren()) {
g_lua.newTable(); g_lua.newTable();
bool pushedChild = false; bool pushedChild = false;
int currentIndex = 1;
for(const OTMLNodePtr& cnode : node->children()) { for(const OTMLNodePtr& cnode : node->children()) {
if(cnode->isUnique()) { push_otml_subnode_luavalue(cnode);
push_luavalue(cnode); if(!g_lua.isNil()) {
if(!g_lua.isNil()) { if(cnode->isUnique()) {
g_lua.setField(cnode->tag()); g_lua.pushString(cnode->tag());
pushedChild = true; g_lua.rawSet();
} else } else
g_lua.pop(); g_lua.rawSeti(currentIndex++);
} pushedChild = true;
} else
g_lua.pop();
} }
if(!pushedChild) { if(!pushedChild) {
g_lua.pop(); g_lua.pop();

@ -364,6 +364,9 @@ void UIWidget::unlockChild(const UIWidgetPtr& child)
void UIWidget::applyStyle(const OTMLNodePtr& styleNode) void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
{ {
if(styleNode->size() == 0)
return;
m_loadingStyle = true; m_loadingStyle = true;
try { try {
onStyleApply(styleNode->tag(), styleNode); onStyleApply(styleNode->tag(), styleNode);

Loading…
Cancel
Save