matlab 判断鼠标按下,Matlab:如何通过使用回调来获取当前鼠标在点击位置
I googled near and far, but couldn't get an example of how you associate a callback to the click event in matlab. Can someone show me an example?
解決方案
Define the WindowButtonDownFcn of your figure callback using the set command and an @callbackfunction tag.
Like so:
function mytestfunction()
f=figure;
set(f,'WindowButtonDownFcn',@mytestcallback)
function mytestcallback(hObject,~)
pos=get(hObject,'CurrentPoint');
disp(['You clicked X:',num2str(pos(1)),', Y:',num2str(pos(2))]);
You can also pass extra variables to callback functions using cell notation:
set(f,'WindowsButtonDownFcn',{@mytestcallback,mydata})
If you're working with uicontrol objects, then it's:
set(myuicontrolhandle,'Callback',@mytestcallback)
總結
以上是生活随笔為你收集整理的matlab 判断鼠标按下,Matlab:如何通过使用回调来获取当前鼠标在点击位置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 山药大枣红糖泡水的功效与作用、禁忌和食用
- 下一篇: 冬虫夏草泡酒的功效与作用、禁忌和食用方法