GWEN
GWEN copied to clipboard
slider call SetFloatValue without calling onValueChanged
Hi,
I need to set the float value for a slider without calling the onValueChanged handler which should only be called when the value is set by the mouse click on the slider. I looked at the Slider source code and this seems not possible without changing the SetFloatValue signature to allow an extra parameter "ignoreEvent" or something like that. This would be my approach, but I want to double check if I'm the only one that needs this feature and if there is a work around with the current api.
thanks.
I recommend you add this functionality in to a fork. Other controls have a doEvents boolean in their parameters that defaults to true.
would be nice to implement the same thing for all the controls, perhaps this should be in Controls::Base?
What? Why would all controls need to set a float value? Here is an example from Label.cpp :
void Label::SetText( const TextObject & str, bool bDoEvents )
{
if ( m_Text->GetText() == str.GetUnicode() ) { return; }
m_Text->SetString( str );
Redraw();
if ( bDoEvents )
{ OnTextChanged(); }
}
I think a lot of code encapsulation is violated by Gwen's design. Even Base::SetValue( const TextObject & ) was not a good idea in opinion because not all controls have a string value.
I mean all the controls should have a variable to ignore the callback
I personally like the current way of just having a boolean on each function that may affect events that can be set to false to not do the event.