# HG changeset patch # User Pantxo Diribarne # Date 1516636019 -3600 # Node ID 9d01ce02d5cb7d16efbaf0a585de5d2e3596990c # Parent b708857d634e9632a646c63f655e156174f828d9 Make selection and "HitTest" compatible with Matlab (bug #52795). * GLCanvas.cc (GLCanvas::selectFromAxes): Don't take "HitTest" into account during selection. * Canvas.cc (Canvas::canvasMousePressEvent): If the selected object has "HitTest"->"off" then replace it with the first ancestor with "HitTest"->"on" or fallback to empty matrix. * NEWS: Announce that HitTest property is now fully implemented. diff -r b708857d634e -r 9d01ce02d5cb NEWS --- a/NEWS Tue Jan 23 10:45:23 2018 +0100 +++ b/NEWS Mon Jan 22 16:46:59 2018 +0100 @@ -74,7 +74,10 @@ ** The graphic object property "Interruptible" has been fully implemented which controls whether a running callback function can - be interrupted by another callback function. + be interrupted by another callback function. + + ** The graphic object property "HitTest" has been updated to be fully + compatible with Matlab. ** Text objects now implement the properties "BackgroundColor", "EdgeColor", "LineStyle", "LineWidth", and "Margin". diff -r b708857d634e -r 9d01ce02d5cb libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Tue Jan 23 10:45:23 2018 +0100 +++ b/libgui/graphics/Canvas.cc Mon Jan 22 16:46:59 2018 +0100 @@ -636,6 +636,20 @@ // clicks. if (! currentObj.valid_object ()) currentObj = figObj; + else if (! currentObj.get_properties ().is_hittest ()) + { + // Objects with "hittest"->"off" pass the mouse event to their + // parent and so on. + graphics_object tmpgo; + tmpgo = gh_manager::get_object (currentObj.get_parent ()); + while (tmpgo && ! tmpgo.get_properties ().is_hittest ()) + tmpgo = gh_manager::get_object (tmpgo.get_parent ()); + + if (tmpgo && tmpgo.get_handle () != 0.0) + currentObj = tmpgo; + else + currentObj = graphics_object (); + } if (axesObj) { @@ -660,7 +674,8 @@ // Update the figure "currentobject" auto& fprop = Utils::properties
(figObj); - if (currentObj.get_properties ().handlevisibility_is ("on")) + if (currentObj + && currentObj.get_properties ().handlevisibility_is ("on")) fprop.set_currentobject (currentObj.get_handle () .as_octave_value ()); else @@ -678,13 +693,13 @@ button_number (event)); // Execute the "buttondownfcn" of the selected object - if (! currentObj.get ("buttondownfcn").isempty ()) + if (currentObj && ! currentObj.get ("buttondownfcn").isempty ()) gh_manager::post_callback (currentObj.get_handle (), "buttondownfcn", button_number (event)); // Show context menu of the selected object - if (event->button () == Qt::RightButton) + if (currentObj && event->button () == Qt::RightButton) ContextMenu::executeAt (currentObj.get_properties (), event->globalPos ()); } diff -r b708857d634e -r 9d01ce02d5cb libgui/graphics/GLCanvas.cc --- a/libgui/graphics/GLCanvas.cc Tue Jan 23 10:45:23 2018 +0100 +++ b/libgui/graphics/GLCanvas.cc Mon Jan 22 16:46:59 2018 +0100 @@ -117,7 +117,8 @@ octave::opengl_selector s; s.set_viewport (width (), height ()); - return s.select (ax, pt.x (), height () - pt.y ()); + return s.select (ax, pt.x (), height () - pt.y (), + octave::select_ignore_hittest); } return graphics_object ();