changeset 20156: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 4910b70d7328
children fc6c87e254bf
files scripts/plot/util/ginput.m
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/ginput.m
+++ b/scripts/plot/util/ginput.m
@@ -64,12 +64,12 @@
   x = y = button = [];
   ginput_accumulator (0, 0, 0, 0);  # initialize accumulator
 
-  orig_buttondownfcn = get (fig, "buttondownfcn");
+  orig_windowbuttondownfcn = get (fig, "windowbuttondownfcn");
   orig_ginput_keypressfcn = get (fig, "keypressfcn");
 
   unwind_protect
 
-    set (ax, "buttondownfcn", @ginput_buttondownfcn);
+    set (fig, "windowbuttondownfcn", @ginput_windowbuttondownfcn);
     set (fig, "keypressfcn", @ginput_keypressfcn);
 
     do
@@ -91,7 +91,7 @@
     endif
 
   unwind_protect_cleanup
-    set (ax, "buttondownfcn", orig_buttondownfcn);
+    set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn);
     set (fig, "keypressfcn", orig_ginput_keypressfcn);
   end_unwind_protect
 
@@ -119,8 +119,8 @@
 
 endfunction
 
-function ginput_buttondownfcn (src, button)
-  point = get (src, "currentpoint");
+function ginput_windowbuttondownfcn (src, button)
+  point = get (gca (), "currentpoint");
   ginput_accumulator (1, point(1,1), point(1,2), button);
 endfunction