作者mp19990920 (郝渴连)
标题Re: [讨论] Matlab GUI自动换Pan的写法
时间Sun Nov 10 13:53:15 2013
在 matlab 中,
指定 GUI元件 所管辖的 GUI事件 为 fun 後,
当 该GUI元件 的 GUI事件 一发生 matlab 就会呼叫 fun(x, y),
x 与 y 是由 matlab 自动传入的,
x 是 GUI元件 的 handle,
y 是选择性参数,看该元件与该事件而决定要不传。
目前的例子中:
GUI元件为 figure,
GUI事件为 WindowButtonMotionFcn(x, y),
x 为 figure 的 handle,
y 为 [],
所以 get(x, 'CurrentPoint') 为取得 figure 中的 CurrentPoint 属性。
※ 引述《InoueToro (InoueToro)》之铭言:
: 大大您好
: 不好意思, 小弟GUI刚入门...
: 能否请您解释一下这语法
: @(x, y) disp(get(x, 'CurrentPoint'))
: get一般不是去获取某gca或gco的子属性值吗@@?
: get(x 是指??
: 谢谢教导
: ※ 引述《mp19990920 (郝渴连)》之铭言:
: : to jatj大:
: : mouseoverfcn是啥啊???
: : 我在matlab的help中都找不到耶!
: : to 原PO:
: : 您可以用以下的程式来修改
: : step 1 产生出一张图
: : hFig = figure;
: : step 2 建立滑鼠移动时要呼叫的函数
: : move = @(x, y) disp(get(x, 'CurrentPoint'));
: : step 3 把滑鼠移动要呼叫的函数指定给一开始产生的图
: : set(hFig, 'WindowButtonMotionFcn', move);
: : 此时您的滑鼠在图上移动时,
: : command window 就会把滑鼠的位置显示出来。
: : 总结:
: : figure 内有两个参数,
: : 您可以用 inspect(hFig) 来观察,
: : 一个是 CurrentPoint 一个是 WindowButtonMotionFcn,
: : CurrentPoint 会自己更新我们动不了他,
: : WindowButtonMotionFcn是滑鼠在移动的时候 matlab 会自己呼叫他。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.67.61.203
1F:推 InoueToro:请问在get(x时, 为何x已指定是figure了? 跟@的用法有关? 11/10 17:25
2F:→ mp19990920:建议您在 help 中搜寻 GUI 与 funciton handle 吧 11/11 01:59
3F:推 InoueToro:好 我再念一下书 谢谢 11/11 21:39