summaryrefslogtreecommitdiffstats
path: root/gui/listbox.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2015-07-09 00:19:58 +0200
committerDees Troy <dees_troy@teamw.in>2015-07-14 16:07:11 +0200
commitc01391c12399081eb3c418142c59885f76011145 (patch)
treec394a5d11f5d12a0284b11b0839e5102c7f9ca60 /gui/listbox.cpp
parentgui: keyboard: support longpress label offset, code cleanup (diff)
downloadandroid_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar.gz
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar.bz2
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar.lz
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar.xz
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.tar.zst
android_bootable_recovery-c01391c12399081eb3c418142c59885f76011145.zip
Diffstat (limited to 'gui/listbox.cpp')
-rw-r--r--gui/listbox.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index a60769979..4c9a68ac8 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -58,6 +58,8 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
// Get the currently selected value for the list
DataManager::GetValue(mVariable, currentValue);
}
+ else
+ allowSelection = false; // allows using listbox as a read-only list
// Get the data for the list
child = FindNode(node, "listitem");
@@ -66,15 +68,21 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
ListData data;
attr = child->first_attribute("name");
- if (!attr) return;
- data.displayName = attr->value();
-
- data.variableValue = child->value();
+ if (!attr)
+ continue;
+ data.displayName = gui_parse_text(attr->value());
+ data.variableValue = gui_parse_text(child->value());
if (child->value() == currentValue) {
data.selected = 1;
} else {
data.selected = 0;
}
+ data.action = NULL;
+ xml_node<>* action = child->first_node("action");
+ if (action) {
+ data.action = new GUIAction(action);
+ allowSelection = true;
+ }
mList.push_back(data);
@@ -157,9 +165,12 @@ void GUIListBox::NotifySelect(size_t item_selected)
mList.at(i).selected = 0;
}
if (item_selected < mList.size()) {
- mList.at(item_selected).selected = 1;
- string str = mList.at(item_selected).variableValue;
+ ListData& data = mList.at(item_selected);
+ data.selected = 1;
+ string str = data.variableValue; // [check] should this set currentValue instead?
DataManager::SetValue(mVariable, str);
+ if (data.action)
+ data.action->doActions();
}
mUpdate = 1;
}