1 ## Copyright (C) 2010-2012 Shai Ayal
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} __fltk_ginput__ (@var{f}, @var{n})
21 ## Undocumented internal function.
24 ## This is ginput.m implementation for fltk.
26 ## FIXME -- Key presses cannot toggle menu items nor hotkey functionality
27 ## (grid, autoscale) during ginput!
29 function [x, y, button] = __fltk_ginput__ (f, n = -1)
31 if (isempty (get (f, "currentaxes")))
32 error ("ginput: must have at least one axes");
36 ginput_aggregator (0, 0, 0, 0);
40 orig_windowbuttondownfcn = get (f, "windowbuttondownfcn");
41 set (f, "windowbuttondownfcn", @ginput_windowbuttondownfcn);
43 orig_ginput_keypressfcn = get (f, "keypressfcn");
44 set (f, "keypressfcn", @ginput_keypressfcn);
52 [x, y, n0, button] = ginput_aggregator (-1, 0, 0, 0);
53 if (n0 == n || n0 < 0)
58 unwind_protect_cleanup
59 set (f, "windowbuttondownfcn", orig_windowbuttondownfcn);
60 set (f, "keypressfcn", orig_ginput_keypressfcn);
65 function [x, y, n, button] = ginput_aggregator (mode, xn, yn, btn)
66 persistent x y n button;
75 ## Accept mouse button or key press.
78 button = [button; btn];
81 ## The end due to Enter.
86 function ginput_windowbuttondownfcn (src, data)
87 point = get (get (src,"currentaxes"), "currentpoint");
88 ## FIXME -- How to get the actual mouse button pressed (1,2,3) into
91 ginput_aggregator (1, point(1,1), point(2,1), button);
94 function ginput_keypressfcn (src, evt)
95 point = get (get (src, "currentaxes"), "currentpoint");
96 ## FIXME -- use evt.Key or evt.Character?
100 ginput_aggregator (2, point(1,1), point(2,1), key);
102 ginput_aggregator (1, point(1,1), point(2,1), key);