comparison +draw/prompt_point.m @ 745:00eb5db89da5 feature/grids

Fix bug in draw.promprt_point() Problems with registering events, Fixed by attaching events to the figure instead of the axis
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 28 Mar 2018 12:50:06 +0200
parents 48b6fb693025
children
comparison
equal deleted inserted replaced
744:94bd0f3293c8 745:00eb5db89da5
1 function [p, button] = prompt_point(s,varargin) 1 function [p, button] = prompt_point(s, varargin)
2 default_arg('s',[]) 2 default_arg('s',[])
3 3
4 set(gcf,'Pointer','crosshair') 4 set(gcf,'Pointer','crosshair')
5 5
6 if ~isempty(s) 6 if ~isempty(s)
7 fprintf(s,varargin{:}); 7 fprintf(s, varargin{:});
8 end 8 end
9 9
10 a = gca; 10 fh = gcf();
11 ah = gca();
11 12
12 function get_point(src,event) 13 function get_point(src, event)
13 cp = a.CurrentPoint; 14 cp = ah.CurrentPoint;
14 p = cp(1,1:2)'; 15 p = cp(1,1:2)';
15 a.ButtonDownFcn = []; 16 fh.WindowButtonUpFcn = [];
16 end 17 end
17 18
18 a.ButtonDownFcn = @get_point; 19 fh.WindowButtonUpFcn = @get_point;
19 waitfor(a,'ButtonDownFcn', []) 20 waitfor(fh,'WindowButtonUpFcn', [])
20 21
21 set(gcf,'Pointer','arrow') 22 set(gcf,'Pointer','arrow')
22 23
23 end 24 end