From b150276a43d479772eeb3e5b159bbd5c214b5dfb Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 25 Mar 2019 15:38:34 -0500 Subject: Prevent having to double-tap some check boxes Check boxes that do not have a default value set usually required you to tap them twice to toggle them on the very first time. This patch checks the return value from GetValue and sets a default of 0 if the variable does not already exist in the Data Manager. Change-Id: I1ff26e756764ed2a00b10102f13a5bce0119771a --- gui/checkbox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp index 025a803a2..ad16f24c3 100755 --- a/gui/checkbox.cpp +++ b/gui/checkbox.cpp @@ -78,8 +78,13 @@ GUICheckbox::GUICheckbox(xml_node<>* node) if (attr) mVarName = attr->value(); attr = child->first_attribute("default"); - if (attr) + if (attr) { DataManager::SetValue(mVarName, attr->value()); + } else { + int val; + if (DataManager::GetValue(mVarName, val) != 0) + DataManager::SetValue(mVarName, 0); // Prevents check boxes from having to be tapped twice the first time + } } mCheckW = mCheckH = 0; -- cgit v1.2.3