Setting Scrollbar Value Without Value Changed Event

  • 5 Replies
  • 48 Views
Setting Scrollbar Value Without Value Changed Event
« on: 10 September 2019, 14:49:44 »
Is it possible to set the value of a scrollbar without the Value Changed signal being triggered?

In my project, there's a situation where I need to do some validation before allowing the scrollbar's value to actually change. Currently, I'm using the Value Changed signal to begin the validation, but I haven't been able to find a way to force the scrollbar back to it's old value without triggering another Value Changed event.

Re: Setting Scrollbar Value Without Value Changed Event
« Reply #1 on: 10 September 2019, 18:21:35 »
Is it possible to set the value of a scrollbar without the Value Changed signal being triggered?
No, it's exactly purpose of the signal.

In my project, there's a situation where I need to do some validation before allowing the scrollbar's value to actually change. Currently, I'm using the Value Changed signal to begin the validation, but I haven't been able to find a way to force the scrollbar back to it's old value without triggering another Value Changed event.
There isn't any way to set custom validator to the control and check anything before changing. At least now, because it's really useful.
But I think you can bind your check to something else and make scrollbar disabled so one can't change it while state will not state as correct.

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: Setting Scrollbar Value Without Value Changed Event
« Reply #2 on: 10 September 2019, 18:33:09 »
I actually added a way to temporarily disable a signal some time ago just for this kind of situation.

scrollbar->onValueChange.setEnabled(false);
scrollbar->setValue(...);
scrollbar->onValueChange.setEnabled(true);

Re: Setting Scrollbar Value Without Value Changed Event
« Reply #3 on: 10 September 2019, 18:59:30 »
In my project, there's a situation where I need to do some validation before allowing the scrollbar's value to actually change. Currently, I'm using the Value Changed signal to begin the validation, but I haven't been able to find a way to force the scrollbar back to it's old value without triggering another Value Changed event.
There isn't any way to set custom validator to the control and check anything before changing. At least now, because it's really useful.
But I think you can bind your check to something else and make scrollbar disabled so one can't change it while state will not state as correct.

Is it possible to bind to the underlying up/down button presses? I'm unable to disable the scrollbar entirely since the validation may only prevent one direction ie, still able to click/drag in the opposite. I could just use regular buttons and avoid the problem altogether.

I actually added a way to temporarily disable a signal some time ago just for this kind of situation.

scrollbar->onValueChange.setEnabled(false);
scrollbar->setValue(...);
scrollbar->onValueChange.setEnabled(true);

Oh. Well that sounds wonderful. Thanks!  ;D
« Last Edit: 10 September 2019, 19:02:18 by Ahnne Cognita »

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: Setting Scrollbar Value Without Value Changed Event
« Reply #4 on: 10 September 2019, 19:15:14 »
Quote
Is it possible to bind to the underlying up/down button presses?
No, value changed signal is send for every kind of change, no matter whether a an up/down button is pressed, the mouse wheel is scrolled, the track is clicked or the thumb is dragged.

Re: Setting Scrollbar Value Without Value Changed Event
« Reply #5 on: 10 September 2019, 19:23:19 »
I actually added a way to temporarily disable a signal some time ago just for this kind of situation.
That's indeed cool and rarely feature.

I'm unable to disable the scrollbar entirely since the validation may only prevent one direction ie, still able to click/drag in the opposite. I could just use regular buttons and avoid the problem altogether.
Right, it was a long shot.