Mercurial > octave
comparison scripts/plot/util/ginput.m @ 19947:6e5365ee200a
ginput: Fix for clicks outside axes and within multiple axes (bug #44426)
* ginput.m: Use the figure "windowbuttondownfcn" callback instead of the
axes "buttondownfcn" callback. Get mouse click coordinates from gca.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sun, 15 Mar 2015 12:41:05 -0400 |
parents | c040bed12b2e |
children | 3b90259f17f3 |
comparison
equal
deleted
inserted
replaced
19946:4910b70d7328 | 19947:6e5365ee200a |
---|---|
62 endif | 62 endif |
63 | 63 |
64 x = y = button = []; | 64 x = y = button = []; |
65 ginput_accumulator (0, 0, 0, 0); # initialize accumulator | 65 ginput_accumulator (0, 0, 0, 0); # initialize accumulator |
66 | 66 |
67 orig_buttondownfcn = get (fig, "buttondownfcn"); | 67 orig_windowbuttondownfcn = get (fig, "windowbuttondownfcn"); |
68 orig_ginput_keypressfcn = get (fig, "keypressfcn"); | 68 orig_ginput_keypressfcn = get (fig, "keypressfcn"); |
69 | 69 |
70 unwind_protect | 70 unwind_protect |
71 | 71 |
72 set (ax, "buttondownfcn", @ginput_buttondownfcn); | 72 set (fig, "windowbuttondownfcn", @ginput_windowbuttondownfcn); |
73 set (fig, "keypressfcn", @ginput_keypressfcn); | 73 set (fig, "keypressfcn", @ginput_keypressfcn); |
74 | 74 |
75 do | 75 do |
76 if (strcmp (toolkit, "fltk")) | 76 if (strcmp (toolkit, "fltk")) |
77 __fltk_check__ (); | 77 __fltk_check__ (); |
89 y = y(1:n); | 89 y = y(1:n); |
90 button = button(1:n); | 90 button = button(1:n); |
91 endif | 91 endif |
92 | 92 |
93 unwind_protect_cleanup | 93 unwind_protect_cleanup |
94 set (ax, "buttondownfcn", orig_buttondownfcn); | 94 set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn); |
95 set (fig, "keypressfcn", orig_ginput_keypressfcn); | 95 set (fig, "keypressfcn", orig_ginput_keypressfcn); |
96 end_unwind_protect | 96 end_unwind_protect |
97 | 97 |
98 varargout = {x, y, button}; | 98 varargout = {x, y, button}; |
99 | 99 |
117 n = -1; | 117 n = -1; |
118 endif | 118 endif |
119 | 119 |
120 endfunction | 120 endfunction |
121 | 121 |
122 function ginput_buttondownfcn (src, button) | 122 function ginput_windowbuttondownfcn (src, button) |
123 point = get (src, "currentpoint"); | 123 point = get (gca (), "currentpoint"); |
124 ginput_accumulator (1, point(1,1), point(1,2), button); | 124 ginput_accumulator (1, point(1,1), point(1,2), button); |
125 endfunction | 125 endfunction |
126 | 126 |
127 function ginput_keypressfcn (src, evt) | 127 function ginput_keypressfcn (src, evt) |
128 point = get (gca (), "currentpoint"); | 128 point = get (gca (), "currentpoint"); |