📄 tmouse.m
字号:
%本程序在以后的研究中可能能够用到
function tmouse(action)
if nargin==0
action='start';
end
%打开一个图形窗口
switch(action)
%设定鼠标按下的回调命令为'tmouse down'
case 'start'
axis([0 1 0 1]);%图轴范围
box on; %图框
title('click and drag your mouse in this window');
set(gcf,'WindowButtonDownFcn','tmouse down');
%鼠标按下的回调命令
case 'down'
%设定鼠标移动的回调命令为'tmouse move'
set(gcf,'WindowButtonMotionFcn','tmouse move');
%设定鼠标释放的回调命令为'tmouse down'
set(gcf,'WindowButtonUpFcn','tmouse 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(gcf,'WindowButtonMotionFcn','');
%清除鼠标释放的回调命令
set(gcf,'WindowButtonUpFcn','');
%显示鼠标信息
fprintf('mouse up!/n')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -