GUI相应鼠标事件

时间:2023-03-08 16:07:13
GUI相应鼠标事件
 function varargout = GUI18(varargin)
% GUI18 MATLAB code for GUI18.fig
% GUI18, by itself, creates a new GUI18 or raises the existing
% singleton*.
%
% H = GUI18 returns the handle to a new GUI18 or the handle to
% the existing singleton*.
%
% GUI18('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI18.M with the given input arguments.
%
% GUI18('Property','Value',...) creates a new GUI18 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI18_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI18_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GUI18 % Last Modified by GUIDE v2. -Jan- :: % Begin initialization code - DO NOT EDIT
gui_Singleton = ;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI18_OpeningFcn, ...
'gui_OutputFcn', @GUI18_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{})
gui_State.gui_Callback = str2func(varargin{});
end if nargout
[varargout{:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT % --- Executes just before GUI18 is made visible.
function GUI18_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI18 (see VARARGIN) % Choose default command line output for GUI18
handles.output = hObject; global ButtonDown pos1;
ButtonDown = [];
pos1 = []; % Update handles structure
guidata(hObject, handles); % UIWAIT makes GUI18 wait for user response (see UIRESUME)
% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.
function varargout = GUI18_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) global ButtonDown pos1;
if strcmp(get(gcf,'SelectionType'),'normal')
ButtonDown = ;
pos1 = get (handles.axes1,'CurrentPoint');
end % Get default command line output from handles structure
varargout{} = handles.output; % --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) global ButtonDown pos1 if ButtonDown ==
pos = get (handles.axes1,'CurrentPoint');
line([pos1(,) pos(,)],[pos1(,) pos(,)],'LineWidth',);
pos1=pos;
end % --- Executes on key release with focus on figure1 or any of its controls.
function figure1_WindowKeyReleaseFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.FIGURE)
% Key: name of the key that was released, in lower case
% Character: character interpretation of the key(s) that was released
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) released
% handles structure with handles and user data (see GUIDATA) % --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ButtonDown
ButtonDown = ;

画线:

GUI相应鼠标事件

GUI相应鼠标事件