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
No products are associated with this question.
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.
Play games and win prizes!Learn more