diff scripts/plot/util/pan.m @ 19923:e1d7bd38b82b

make pan, rotate3d, and zoom properly toggle state * pan.m (update_mouse_mode): New subfunction. Also set __mouse_mode__ property when toggling state. * rotate3d.m: Likewise. * zoom.m: Likewise.
author John W. Eaton <jwe@octave.org>
date Mon, 02 Mar 2015 21:00:13 -0500
parents 4197fc428c7d
children 777f26aa8e3e
line wrap: on
line diff
--- a/scripts/plot/util/pan.m	Mon Mar 02 20:48:00 2015 -0500
+++ b/scripts/plot/util/pan.m	Mon Mar 02 21:00:13 2015 -0500
@@ -76,6 +76,7 @@
       pm.Enable = "on";
     endif
     set (hfig, "__pan_mode__", pm);
+    update_mouse_mode (hfig, pm.Enable);
   elseif (nargs == 1)
     arg = varargin{1};
     if (ischar (arg))
@@ -94,17 +95,7 @@
               pm.Motion = "vertical";
           endswitch
           set (hfig, "__pan_mode__", pm);
-          if (strcmp (arg, "off"))
-            set (hfig, "__mouse_mode__", "none");
-          else
-            ## FIXME: Is there a better way other than calling these
-            ## functions to set the other mouse mode Enable fields to
-            ## "off"?
-            rotate3d ("off");
-            zoom ("off");
-            set (hfig, "__mouse_mode__", "pan");
-          endif
-
+          update_mouse_mode (hfig, arg);
         otherwise
           error ("pan: unrecognized option '%s'", arg);
       endswitch
@@ -115,3 +106,15 @@
 
 endfunction
 
+function update_mouse_mode (hfig, arg)
+  if (strcmp (arg, "off"))
+    set (hfig, "__mouse_mode__", "none");
+  else
+    ## FIXME: Is there a better way other than calling these
+    ## functions to set the other mouse mode Enable fields to
+    ## "off"?
+    rotate3d ("off");
+    zoom ("off");
+    set (hfig, "__mouse_mode__", "pan");
+  endif
+endfunction