Handle spinner custom text differently differently to fix issue #1837 problem with activation/deactivation and updategfxSlider
This commit is contained in:
parent
a41cac02a2
commit
7f6a1dfd56
@ -326,6 +326,7 @@ void SpinnerWidget::addLabel(stringw label)
|
|||||||
void SpinnerWidget::setValue(const int new_value)
|
void SpinnerWidget::setValue(const int new_value)
|
||||||
{
|
{
|
||||||
m_value = new_value;
|
m_value = new_value;
|
||||||
|
m_customText = "";
|
||||||
|
|
||||||
if (m_graphical)
|
if (m_graphical)
|
||||||
{
|
{
|
||||||
@ -397,7 +398,14 @@ void SpinnerWidget::setActivated()
|
|||||||
Widget::setActivated();
|
Widget::setActivated();
|
||||||
|
|
||||||
setText(L"");
|
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();
|
Widget::setDeactivated();
|
||||||
|
|
||||||
|
// Save it temporarary because setValue(which is uses for update in this case) overwrite it
|
||||||
|
core::stringw customText = customText;
|
||||||
setText(L"-");
|
setText(L"-");
|
||||||
setValue( getValue() ); // Update the display
|
setValue(getValue()); // Update the display
|
||||||
|
m_customText = customText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void SpinnerWidget::setCustomText(const core::stringw& text)
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,11 @@ namespace GUIEngine
|
|||||||
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
|
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
|
||||||
bool m_wrap_around;
|
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 */
|
/** \brief implementing method from base class Widget */
|
||||||
virtual EventPropagation transmitEvent(Widget* w,
|
virtual EventPropagation transmitEvent(Widget* w,
|
||||||
const std::string& originator,
|
const std::string& originator,
|
||||||
|
Loading…
Reference in New Issue
Block a user