# HG changeset patch # User John W. Eaton # Date 1425348013 18000 # Node ID e1d7bd38b82b0d28320759aa885ff1124975f924 # Parent 966a1933f3fa0489b7184674859c53ba26ef3316 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. diff -r 966a1933f3fa -r e1d7bd38b82b scripts/plot/util/pan.m --- 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 diff -r 966a1933f3fa -r e1d7bd38b82b scripts/plot/util/rotate3d.m --- a/scripts/plot/util/rotate3d.m Mon Mar 02 20:48:00 2015 -0500 +++ b/scripts/plot/util/rotate3d.m Mon Mar 02 21:00:13 2015 -0500 @@ -71,6 +71,7 @@ rm.Enable = "on"; endif set (hfig, "__rotate_mode__", rm); + update_mouse_mode (hfig, rm.Enable); elseif (nargs == 1) arg = varargin{1}; if (ischar (arg)) @@ -83,17 +84,7 @@ rm.Motion = "both"; endswitch set (hfig, "__rotate_mode__", rm); - 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"? - pan ("off"); - zoom ("off"); - set (hfig, "__mouse_mode__", "rotate"); - endif - + update_mouse_mode (hfig, arg); otherwise error ("rotate3d: unrecognized option '%s'", arg); endswitch @@ -104,3 +95,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"? + pan ("off"); + zoom ("off"); + set (hfig, "__mouse_mode__", "rotate"); + endif +endfunction diff -r 966a1933f3fa -r e1d7bd38b82b scripts/plot/util/zoom.m --- a/scripts/plot/util/zoom.m Mon Mar 02 20:48:00 2015 -0500 +++ b/scripts/plot/util/zoom.m Mon Mar 02 21:00:13 2015 -0500 @@ -92,6 +92,7 @@ zm.Enable = "on"; endif set (hfig, "__zoom_mode__", zm); + update_mouse_mode (hfig, zm.Enable); elseif (nargs == 1) arg = varargin{1}; if (isnumeric (arg)) @@ -141,29 +142,17 @@ zm.Motion = "vertical"; endswitch set (hfig, "__zoom_mode__", zm); - 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"? - pan ("off"); - rotate3d ("off"); - set (hfig, "__mouse_mode__", "zoom"); - endif - + update_mouse_mode (hfig, arg); case "out" cax = get (hfig, "currentaxes"); if (! isempty (cax)) __zoom__ (cax, "out"); endif - case "reset" cax = get (hfig, "currentaxes"); if (! isempty (cax)) __zoom__ (cax, "reset"); endif - otherwise error ("zoom: unrecognized option '%s'", arg); endswitch @@ -174,6 +163,18 @@ 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"? + pan ("off"); + rotate3d ("off"); + set (hfig, "__mouse_mode__", "zoom"); + endif +endfunction %!demo %! clf;