Customize Wheel Scroll fxn to work within axes in figure?
26 ビュー (過去 30 日間)
古いコメントを表示
Hello, thanks for reading this,
I was wondering, is it possible to create a WindowScrollWheelFcn event exclusive to a axes within a figure I create within a UI? As in, when I cross over the axes in the UI I create and THEN scroll down, I do the callback. Otherwise, I do not activate the callback.
I was thinking I could check the mouse position when I do it in a figure, and if its in the domain of the axes, then do the WindowScrollWheelFcn callback, otherwise do nothing. Would this be the way to go about doing this?
Thanks for your help!
0 件のコメント
採用された回答
Joseph Cheng
2014 年 7 月 16 日
編集済み: Joseph Cheng
2014 年 7 月 16 日
i did a quick test script to show you what is possible.
h=figure
p1=subplot(2,1,1),plot(rand(10))
p2=subplot(2,1,2),plot(rand(4))
set(h,'windowscrollWheelFcn', 'plot(rand(10))');
set(h,'Windowbuttonupfcn', 'gca');
so with the snippit you can see that if you click on subplot 1 and scroll wheel it'll peform the random plot and do the same with subplot 2. since we can determine which subplot (or axes) were clicked the callback function can determine what to perform. I show how to determine which item was clicked using the windowbuttonupfcn. So in the windowscrollwheelfcn function you can set up something that checks what is the active axes and perform the scrollwheel function.
4 件のコメント
その他の回答 (2 件)
Brian
2014 年 7 月 16 日
1 件のコメント
Joseph Cheng
2014 年 7 月 17 日
yes. so the first set for the windowscrollwheefcn will perform what will be after. Before I implemented the mouse positioning i used the windowbuttonupfcn to find which axes was last selected. but i realized you want to utilize the mouse positioning to determine which axes is hovered not clicked.
Brian
2014 年 7 月 16 日
2 件のコメント
Joseph Cheng
2014 年 7 月 17 日
yes exactly, in my second comment where I included the mouse positioning, it calls for the function scrollfunc() where you can do something else. I just use plot(rand) as a temporary do something function.
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!