Handle spinner custom text differently differently to fix issue #1837 problem with activation/deactivation and updategfxSlider

This commit is contained in:
Mathieu Laprise 2014-12-27 15:10:39 -05:00
parent a41cac02a2
commit 7f6a1dfd56
2 changed files with 23 additions and 3 deletions

View File

@ -326,6 +326,7 @@ void SpinnerWidget::addLabel(stringw label)
void SpinnerWidget::setValue(const int new_value)
{
m_value = new_value;
m_customText = "";
if (m_graphical)
{
@ -397,7 +398,14 @@ void SpinnerWidget::setActivated()
Widget::setActivated();
setText(L"");
setValue( getValue() ); // Update the display
if (m_customText.empty())
{
setValue(getValue()); // Update the display
}
else
{
setCustomText(m_customText);
}
}
// -----------------------------------------------------------------------------
@ -406,14 +414,21 @@ void SpinnerWidget::setDeactivated()
{
Widget::setDeactivated();
// Save it temporarary because setValue(which is uses for update in this case) overwrite it
core::stringw customText = customText;
setText(L"-");
setValue( getValue() ); // Update the display
setValue(getValue()); // Update the display
m_customText = customText;
}
// -----------------------------------------------------------------------------
void SpinnerWidget::setCustomText(const core::stringw& text)
{
m_children[1].m_element->setText(text.c_str());
m_customText = text;
if (m_children.size() > 0)
{
m_children[1].m_element->setText(text.c_str());
}
}

View File

@ -76,6 +76,11 @@ namespace GUIEngine
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
bool m_wrap_around;
/** \brief Keeps track of the custom text in spinner (a text which isn't related to a value)
* to remember it and set it back (example : when we deactivate the widget)
*/
core::stringw m_customText;
/** \brief implementing method from base class Widget */
virtual EventPropagation transmitEvent(Widget* w,
const std::string& originator,