[討論] GUI視窗中限定滑鼠只能在某個axes上操作已回收
某個Button的Callback程式碼如下:
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
action='start';
axes(handles.axes2);
switch(action)
case 'start' % 開啟圖形視窗
set(gca, 'WindowButtonDownFcn', 'mouse03 down');
case 'down' % 滑鼠按鈕被按下時的反應指令
set(gca, 'WindowButtonMotionFcn', 'mouse03 move');
set(gca, 'WindowButtonUpFcn', 'mouse03 up');
fprintf('Mouse down!\n');
case 'move' % 滑鼠移動時的反應指令
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1); y = currPt(1,2);
line(x, y, 'marker', '.', 'EraseMode', 'xor');
fprintf('Mouse is moving! Current location = (%g, %g)\n', ...
currPt(1,1), currPt(1,2));
case 'up' % 滑鼠按鈕被釋放時的反應指令
set(gca, 'WindowButtonMotionFcn', '');
set(gca, 'WindowButtonUpFcn', '');
fprintf('Mouse up!\n');
end
我想限制滑鼠只能在axes2的視窗上做動作,但是每次執行時都會出現
??? Error using ==> set
There is no 'WindowButtonDownFcn' property in the 'axes' class.
Error in ==> test_06_11>pushbutton7_Callback at 340
set(gca, 'WindowButtonDownFcn', 'mouse03 down');
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> test_06_11 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)test_06_11('pushbutton7_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
請問一下要如何將滑鼠操作指令限定在某個axes上操做呢?
感激不盡~~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.149.224
推
06/15 14:19, , 1F
06/15 14:19, 1F
→
06/15 16:32, , 2F
06/15 16:32, 2F