Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Mouse scroll wheel for uicontrol slider

Subject: Mouse scroll wheel for uicontrol slider

From: Boris

Date: 25 Jan, 2013 19:10:08

Message: 1 of 4

Hi all,

I have recently begun using MATLAB 2010b and have a question about using the mouse scroll wheel in guis.

I am working on a gui that has within it a uipanel with a 'slider' type uicontrol which scrolls through a number of axes. Everything is working properly, however I would like the slider to be able to be controlled by the scroll wheel on the mouse.

I searched extensively for functions that could implement this, but all I found was the WindowsScrollWheelFcn, which is for figure type objects, not uicontrol types. I do not think that the function would work for uicontrol sliders, but perhaps it does?

If anyone knows how to get the mouse scroll wheel to work for uicontrol sliders, I would really appreciate being pointed in the right direction. This is a relatively small part of the whole gui so I do not think it would be worth it for me to rewrite everything into a figure just to get the scroll wheel working, but I would be open to hearing such suggestions.

Thanks for the help,
Boris

Subject: Mouse scroll wheel for uicontrol slider

From: Doug Schwarz

Date: 26 Jan, 2013 01:24:44

Message: 2 of 4

In article <kdulag$b1i$1@newscl01ah.mathworks.com>,
 "Boris " <bmateev@ymail.com> wrote:

> Hi all,
>
> I have recently begun using MATLAB 2010b and have a question about using the
> mouse scroll wheel in guis.
>
> I am working on a gui that has within it a uipanel with a 'slider' type
> uicontrol which scrolls through a number of axes. Everything is working
> properly, however I would like the slider to be able to be controlled by the
> scroll wheel on the mouse.
>
> I searched extensively for functions that could implement this, but all I
> found was the WindowsScrollWheelFcn, which is for figure type objects, not
> uicontrol types. I do not think that the function would work for uicontrol
> sliders, but perhaps it does?
>
> If anyone knows how to get the mouse scroll wheel to work for uicontrol
> sliders, I would really appreciate being pointed in the right direction. This
> is a relatively small part of the whole gui so I do not think it would be
> worth it for me to rewrite everything into a figure just to get the scroll
> wheel working, but I would be open to hearing such suggestions.
>
> Thanks for the help,
> Boris

Boris,

The WindowsScrollWheelFcn for the figure is the right thing to use. If
you want the scroll wheel to "operate" multiple sliders, you'd have to
have a way to select which slider to "operate." You could either use
the last slider touched or perhaps use the slider closest to the current
pointer position. In any case, just program the scroll wheel function
to run the same (or similar) function as the slider. It won't be
connected to the slider, it'll just do the same thing. You can have it
update the slider, too, if you want by setting the slider value.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: Mouse scroll wheel for uicontrol slider

From: Boris

Date: 28 Jan, 2013 19:27:09

Message: 3 of 4

> Boris,
>
> The WindowsScrollWheelFcn for the figure is the right thing to use. If
> you want the scroll wheel to "operate" multiple sliders, you'd have to
> have a way to select which slider to "operate." You could either use
> the last slider touched or perhaps use the slider closest to the current
> pointer position. In any case, just program the scroll wheel function
> to run the same (or similar) function as the slider. It won't be
> connected to the slider, it'll just do the same thing. You can have it
> update the slider, too, if you want by setting the slider value.
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.

Thanks for the response Doug.

I have code implementing WindowScrollWheelFcn working now, however I have to create a new figure to use the function. From there I edit my slider position based off the scroll wheel movements inside the new figure.

The problem is that I want the scroll panel to move when the mouse is moved over the uicontrol slider, not some random figure that I am not even using. I tried making a WindowScrollWheelFcn callback in the uicontrol, but an error said that uicontrols do not have such a field.

So I guess my question is is it possible to use the WindowScrollWheelFcn without having any figure, just uicontrol objects?

Thanks,
Boris

Subject: Mouse scroll wheel for uicontrol slider

From: Steven_Lord

Date: 28 Jan, 2013 21:43:37

Message: 4 of 4



"Boris " <bmateev@ymail.com> wrote in message
news:ke6jed$li2$1@newscl01ah.mathworks.com...
>> Boris,
>>
>> The WindowsScrollWheelFcn for the figure is the right thing to use. If
>> you want the scroll wheel to "operate" multiple sliders, you'd have to
>> have a way to select which slider to "operate." You could either use the
>> last slider touched or perhaps use the slider closest to the current
>> pointer position. In any case, just program the scroll wheel function to
>> run the same (or similar) function as the slider. It won't be connected
>> to the slider, it'll just do the same thing. You can have it update the
>> slider, too, if you want by setting the slider value.
>>
>> --
>> Doug Schwarz
>> dmschwarz&ieee,org
>> Make obvious changes to get real email address.
>
> Thanks for the response Doug.
>
> I have code implementing WindowScrollWheelFcn working now, however I have
> to create a new figure to use the function. From there I edit my slider
> position based off the scroll wheel movements inside the new figure.
> The problem is that I want the scroll panel to move when the mouse is
> moved over the uicontrol slider, not some random figure that I am not even
> using. I tried making a WindowScrollWheelFcn callback in the uicontrol,
> but an error said that uicontrols do not have such a field.
> So I guess my question is is it possible to use the WindowScrollWheelFcn
> without having any figure, just uicontrol objects?

If you have uicontrol objects, you DO have a figure -- the figure in which
the uicontrols are located. Set the WindowScrollWheelFcn for that figure
(you can use ANCESTOR with the slider handle to locate that figure's handle
if you don't have access to it for whatever reason.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

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.

Contact us