changeset 26861:6236c790bd1b

Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848) * Canvas.cc (Canvas::canvasMousePressEvent): Add new bool variable that is false for legend, colorbar and axes with handlevisibility "off". Use it to prevent pan, zoom and rotate from acting on those axes objects.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 07 Mar 2019 16:31:51 +0100
parents 7c9a681c4474
children ea4a36fd48b6
files libgui/graphics/Canvas.cc
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc	Thu Mar 07 10:52:18 2019 -0800
+++ b/libgui/graphics/Canvas.cc	Thu Mar 07 16:31:51 2019 +0100
@@ -639,14 +639,15 @@
               currentObj = graphics_object ();
           }
 
-        if (axesObj)
-          {
-            if (axesObj.get_properties ().handlevisibility_is ("on")
-                && axesObj.get_properties ().get_tag () != "legend"
-                && axesObj.get_properties ().get_tag () != "colorbar")
-              Utils::properties<figure> (figObj)
-              .set_currentaxes (axesObj.get_handle ().as_octave_value ());
-          }
+        // Make selected axes current
+        bool valid_axes = axesObj.valid_object ()
+          && axesObj.get_properties ().handlevisibility_is ("on")
+          && axesObj.get_properties ().get_tag () != "legend"
+          && axesObj.get_properties ().get_tag () != "colorbar";
+        
+        if (valid_axes)
+          Utils::properties<figure> (figObj)
+            .set_currentaxes (axesObj.get_handle ().as_octave_value ());
 
         Figure *fig = dynamic_cast<Figure *> (Backend::toolkitObject (figObj));
 
@@ -718,7 +719,7 @@
           case RotateMode:
           case ZoomInMode:
           case ZoomOutMode:
-            if (axesObj && axesObj.get_properties ().handlevisibility_is ("on"))
+            if (valid_axes)
               {
                 bool redraw_figure = true;