annotate scripts/plot/util/ginput.m @ 20197:2283dd03bf50

ginput.m: Don't hang if window is close while fcn active (bug #44897). * ginput.m: Change closerequestfcn for figure to point to ginput_closerequestfcn. * ginput.m (ginput_closerequestfcn): New callback routine. Stops collecting data for ginput. Calls original closerequestfcn to shutdown window.
author Rik <rik@octave.org>
date Fri, 15 May 2015 16:51:57 -0700
parents 0b83a442ff78
children b93a155dc200
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19013
diff changeset
1 ## Copyright (C) 2008-2015 David Bateman
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
20 ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} ginput (@var{n})
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
21 ## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{buttons}] =} ginput ()
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
22 ## Return the position and type of mouse button clicks and/or key strokes
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
23 ## in the current figure window.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
24 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
25 ## If @var{n} is defined, then capture @var{n} events before returning.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
26 ## When @var{n} is not defined @code{ginput} will loop until the return key
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
27 ## @key{RET} is pressed.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
28 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
29 ## The return values @var{x}, @var{y} are the coordinates where the mouse
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
30 ## was clicked in the units of the current axes. The return value @var{button}
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
31 ## is 1, 2, or 3 for the left, middle, or right button. If a key is pressed
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
32 ## the ASCII value is returned in @var{button}.
20073
3b90259f17f3 Document that ginput() is intended for 2-D plots (bug #44427).
Rik <rik@octave.org>
parents: 19947
diff changeset
33 ##
3b90259f17f3 Document that ginput() is intended for 2-D plots (bug #44427).
Rik <rik@octave.org>
parents: 19947
diff changeset
34 ## Implementation Note: @code{ginput} is intenteded for 2-D plots. For 3-D
3b90259f17f3 Document that ginput() is intended for 2-D plots (bug #44427).
Rik <rik@octave.org>
parents: 19947
diff changeset
35 ## plots see the @var{currentpoint} property of the current axes which can be
3b90259f17f3 Document that ginput() is intended for 2-D plots (bug #44427).
Rik <rik@octave.org>
parents: 19947
diff changeset
36 ## transformed with knowledge of the current @code{view} into data units.
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17122
diff changeset
37 ## @seealso{gtext, waitforbuttonpress}
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
38 ## @end deftypefn
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
39
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
40 function varargout = ginput (n = -1)
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
41
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
42 if (nargin > 1)
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 print_usage ();
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 endif
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
45
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
46 ## Create an axis, if necessary.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
47 fig = gcf ();
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
48 ax = gca ();
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 drawnow ();
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
50
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
51 if (isempty (ax))
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
52 error ("ginput: must have at least one axes");
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
53 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
54
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
55 toolkit = get (fig, "__graphics_toolkit__");
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
56 toolkit_fcn = sprintf ("__%s_ginput__", toolkit);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
57
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
58 if (exist (toolkit_fcn))
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
59 varargout = cell (1, nargout);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
60 if (nargin == 0)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
61 [varargout{:}] = feval (toolkit_fcn, fig);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
62 else
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
63 [varargout{:}] = feval (toolkit_fcn, fig, n);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
64 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
65 return
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
66 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
67
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
68 x = y = button = [];
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
69 ginput_accumulator (0, 0, 0, 0); # initialize accumulator
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
70
19947
6e5365ee200a ginput: Fix for clicks outside axes and within multiple axes (bug #44426)
Mike Miller <mtmiller@octave.org>
parents: 19764
diff changeset
71 orig_windowbuttondownfcn = get (fig, "windowbuttondownfcn");
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
72 orig_keypressfcn = get (fig, "keypressfcn");
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
73 orig_closerequestfcn = get (fig, "closerequestfcn");
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
74
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
75 unwind_protect
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
76
19947
6e5365ee200a ginput: Fix for clicks outside axes and within multiple axes (bug #44426)
Mike Miller <mtmiller@octave.org>
parents: 19764
diff changeset
77 set (fig, "windowbuttondownfcn", @ginput_windowbuttondownfcn);
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
78 set (fig, "keypressfcn", @ginput_keypressfcn);
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
79 set (fig, "closerequestfcn", {@ginput_closerequestfcn,
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
80 orig_closerequestfcn});
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
81
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
82 do
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
83 if (strcmp (toolkit, "fltk"))
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
84 __fltk_check__ ();
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
85 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
86
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
87 ## Release CPU.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
88 sleep (0.01);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
89
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
90 [x, y, n0, button] = ginput_accumulator (-1, 0, 0, 0);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
91 until ((n > -1 && n0 >= n) || n0 < 0)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
92
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
93 if (n0 > n)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
94 ## More clicks than requested due to double-click or too fast clicking
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
95 x = x(1:n);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
96 y = y(1:n);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
97 button = button(1:n);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
98 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
99
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
100 unwind_protect_cleanup
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
101 if (isfigure (fig))
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
102 ## Only execute if window still exists
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
103 set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn);
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
104 set (fig, "keypressfcn", orig_keypressfcn);
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
105 endif
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
106 end_unwind_protect
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
107
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
108 varargout = {x, y, button};
7673
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
109
e0c930dda642 ginput: new function
David Bateman <dbateman@free.fr>
parents:
diff changeset
110 endfunction
13123
6efa1a691713 Add further tests for scripts/plot.
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
111
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
112 function [x, y, n, button] = ginput_accumulator (mode, xn, yn, btn)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
113 persistent x y n button;
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
114
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
115 if (mode == 0)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
116 ## Initialize.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
117 x = y = button = [];
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
118 n = 0;
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
119 elseif (mode == 1)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
120 ## Append mouse button or key press.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
121 x = [x; xn];
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
122 y = [y; yn];
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
123 button = [button; btn];
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
124 n += 1;
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
125 elseif (mode == 2)
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
126 ## The end due to Enter.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
127 n = -1;
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
128 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
129
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
130 endfunction
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
131
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
132 function ginput_windowbuttondownfcn (~, button)
19947
6e5365ee200a ginput: Fix for clicks outside axes and within multiple axes (bug #44426)
Mike Miller <mtmiller@octave.org>
parents: 19764
diff changeset
133 point = get (gca (), "currentpoint");
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
134 ginput_accumulator (1, point(1,1), point(1,2), button);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
135 endfunction
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
136
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
137 function ginput_keypressfcn (~, evt)
19764
c040bed12b2e * ginput.m: Fix botched search and replace in previous change.
John W. Eaton <jwe@octave.org>
parents: 19748
diff changeset
138 point = get (gca (), "currentpoint");
20094
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
139 if (strcmp (evt.Key, "return"))
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
140 ## Enter key stops ginput.
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
141 ginput_accumulator (2, NaN, NaN, NaN);
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
142 else
20094
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
143 character = evt.Character;
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
144 if (! isempty (character))
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
145 ginput_accumulator (1, point(1,1), point(1,2), uint8 (character(1)));
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
146 endif
19748
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
147 endif
3fc946d5e91f make ginput work for all toolkits again (bug #41977)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
148 endfunction
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
149
20197
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
150 function ginput_closerequestfcn (hfig, ~, orig_closerequestfcn)
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
151 ginput_accumulator (2, NaN, NaN, NaN); # Stop ginput
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
152 feval (orig_closerequestfcn); # Close window with original fcn
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
153 endfunction
2283dd03bf50 ginput.m: Don't hang if window is close while fcn active (bug #44897).
Rik <rik@octave.org>
parents: 20094
diff changeset
154
20094
0b83a442ff78 Process SHIFT/CTRL/ALT keys properly for ginput (Bug #44833).
Rik <rik@octave.org>
parents: 20073
diff changeset
155
13123
6efa1a691713 Add further tests for scripts/plot.
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
156 ## Remove from test statistics. No real tests possible.
6efa1a691713 Add further tests for scripts/plot.
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
157 %!test
6efa1a691713 Add further tests for scripts/plot.
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
158 %! assert (1);