Mouse Slider capability in uicontrol slider

20 Ansichten (letzte 30 Tage)
Boris
Boris am 25 Jan. 2013
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

Antworten (1)

Jan
Jan am 25 Jan. 2013
Yair's FEX: findjobj allows to access the underlying capabilities of the uicontrols:
hButton = uicontrol('style', 'slider');
jButton = findjobj(hButton);
jButton.MouseWheelMovedCallback = 'disp(clock)'
Now the moving the mouse wheel triggers the callback. But the slider must be the current object also, so you need to click on it at first.
The MouseMotionCallback of the figure can move the focus to the slider when the mouse is moved on top.
On the other hand, the WindowsScrollWheelFcn is not a bad idea also. Whenever the mouse is over the slider, let this callback move the slider. This is more direct then the indirection over the Java methods of the slider, although this is a contradiction to the actually clear object oriented structure of a GUI.
  1 Kommentar
Boris
Boris am 28 Jan. 2013
Thanks for the response Jan.
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Desktop finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by