diff libgui/graphics/BaseControl.cc @ 25996:37743ef71734

Let uicontrol objects become the figure currentobject when clicked (bug #44672) * BaseControl.cc (BaseControl::eventFilter): When a uicontrol is clicked the update its parent figure "currentobject" property.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 01 Nov 2018 14:28:27 +0100
parents 9c47eedc44e2
children 80c8062e855a
line wrap: on
line diff
--- a/libgui/graphics/BaseControl.cc	Thu Nov 01 13:30:03 2018 +0100
+++ b/libgui/graphics/BaseControl.cc	Thu Nov 01 14:28:27 2018 +0100
@@ -199,30 +199,35 @@
           graphics_object go = object ();
           uicontrol::properties& up = Utils::properties<uicontrol> (go);
           graphics_object fig = go.get_ancestor ("figure");
-
-          if (fig && (m->button () != Qt::LeftButton
-                      || ! up.enable_is ("on")))
+          if (fig)
             {
-              gh_manager::post_set (fig.get_handle (), "selectiontype",
-                                    Utils::figureSelectionType (m), false);
-              gh_manager::post_set (fig.get_handle (), "currentpoint",
-                                    Utils::figureCurrentPoint (fig, m),
-                                    false);
-              gh_manager::post_callback (fig.get_handle (),
-                                         "windowbuttondownfcn");
-              gh_manager::post_callback (m_handle, "buttondownfcn");
+              gh_manager::post_set (fig.get_handle (), "currentobject",
+                                    m_handle.value (), false);
+              
+              if (m->button () != Qt::LeftButton || ! up.enable_is ("on"))
+                {
+                  gh_manager::post_set (fig.get_handle (), "selectiontype",
+                                        Utils::figureSelectionType (m), false);
+                  gh_manager::post_set (fig.get_handle (), "currentpoint",
+                                        Utils::figureCurrentPoint (fig, m),
+                                        false);
+                  gh_manager::post_callback (fig.get_handle (),
+                                             "windowbuttondownfcn");
+                  gh_manager::post_callback (m_handle, "buttondownfcn");
 
-              if (m->button () == Qt::RightButton)
-                ContextMenu::executeAt (up, m->globalPos ());
-            }
-          else
-            {
-              if (up.style_is ("listbox"))
-                gh_manager::post_set (fig.get_handle (), "selectiontype",
-                                      Utils::figureSelectionType (m), false);
+                  if (m->button () == Qt::RightButton)
+                    ContextMenu::executeAt (up, m->globalPos ());
+                }
               else
-                gh_manager::post_set (fig.get_handle (), "selectiontype",
-                                      octave_value ("normal"), false);
+                {
+                  if (up.style_is ("listbox"))
+                    gh_manager::post_set (fig.get_handle (), "selectiontype",
+                                          Utils::figureSelectionType (m),
+                                          false);
+                  else
+                    gh_manager::post_set (fig.get_handle (), "selectiontype",
+                                          octave_value ("normal"), false);
+                }
             }
         }
         break;