GWEN icon indicating copy to clipboard operation
GWEN copied to clipboard

slider call SetFloatValue without calling onValueChanged

Open q-depot opened this issue 11 years ago • 5 comments

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.

q-depot avatar Jul 17 '13 11:07 q-depot

I recommend you add this functionality in to a fork. Other controls have a doEvents boolean in their parameters that defaults to true.

Wizzard033 avatar Jul 17 '13 22:07 Wizzard033

would be nice to implement the same thing for all the controls, perhaps this should be in Controls::Base?

q-depot avatar Jul 18 '13 07:07 q-depot

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.

Wizzard033 avatar Jul 18 '13 15:07 Wizzard033

I mean all the controls should have a variable to ignore the callback

q-depot avatar Jul 18 '13 16:07 q-depot

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.

Wizzard033 avatar Jul 18 '13 16:07 Wizzard033