Thread Subject:
Slider behavior

Subject: Slider behavior

From: Ted

Date: 27 Jul, 2009 20:36:02

Message: 1 of 3

I have a question about the behavior of the ui slider control.

So I set the slider's interruptible property to off and I set a callback function.

When the user presses and releases an arrow button then for each min-step change (one press-release pair) in the slider's value my callback is executed as I would expect.

Now, when a user presses and holds down a slider arrow button the slider's value increases faster than the callback gets called, that is, there is not a one to one correspondence between the slider value changing by it's min-step value and my callback being called. In other words, each time my callback is called, the slider's value may have changed by 4*min-step. Does that make sense? Is that expected? Is there a way to make the slider call my callback for each min-step change in the slider's value when a user presses and holds down one of the slider's arrow buttons (and like-wise when clicking in the trough and changing the slider's value by max-step)?

Thanks!

Subject: Slider behavior

From: Anil Thota

Date: 11 Aug, 2009 02:22:03

Message: 2 of 3

Ted -- this is expected when the interruptible property is on. If you want to have one-to-one callback then set interruptible property off. This will solve your problem.
Anil
"Ted " <dustman@cvrti.utah.edu> wrote in message <h4l33i$s0q$1@fred.mathworks.com>...
> I have a question about the behavior of the ui slider control.
>
> So I set the slider's interruptible property to off and I set a callback function.
>
> When the user presses and releases an arrow button then for each min-step change (one press-release pair) in the slider's value my callback is executed as I would expect.
>
> Now, when a user presses and holds down a slider arrow button the slider's value increases faster than the callback gets called, that is, there is not a one to one correspondence between the slider value changing by it's min-step value and my callback being called. In other words, each time my callback is called, the slider's value may have changed by 4*min-step. Does that make sense? Is that expected? Is there a way to make the slider call my callback for each min-step change in the slider's value when a user presses and holds down one of the slider's arrow buttons (and like-wise when clicking in the trough and changing the slider's value by max-step)?
>
> Thanks!

Subject: Slider behavior

From: Yair Altman

Date: 11 Aug, 2009 07:49:03

Message: 3 of 3

"Ted " <dustman@cvrti.utah.edu> wrote...

> Now, when a user presses and holds down a slider arrow button the slider's value increases faster than the callback gets called, that is, there is not a one to one correspondence between the slider value changing by it's min-step value and my callback being called. In other words, each time my callback is called, the slider's value may have changed by 4*min-step. Does that make sense? Is that expected? Is there a way to make the slider call my callback for each min-step change in the slider's value when a user presses and holds down one of the slider's arrow buttons (and like-wise when clicking in the trough and changing the slider's value by max-step)?


1. You don't really need your callback called for each single increment. You need to modify your callback to be stateless, meaning that whenever it is called it looks at the current slider (scrollbar) value and acts accordingly. This will reduce CPU and actually improve responsiveness/performance.

2. For for another solution, which also solves the continuous trough/max-step request, see this thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/144980

Yair Altman
http://UndocumentedMatlab.com
 

Tags for this Thread

Everyone's Tags:

slider(2), gui

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
slider Purdue 19 Apr, 2011 16:35:16
gui Sprinceana 22 Aug, 2009 05:31:45
slider Sprinceana 27 Jul, 2009 17:01:23
rssFeed for this Thread

Contact us