diff libgui/graphics/Figure.cc @ 18646:9597e00ed2dd

Add support for "windowbuttonmotionfcn" and "currentpoint" * Figure.cc (Figure::Figure): Enable mouse tracking if windowbuttonmotionfcn callback is defined. (Figure::update): Enable mouse tracking on canvas and all child widgets when windowbuttonmotionfcn is defined. * Panel.cc (Panel::Panel): Propagate mouse tracking to child widgets during initialization. * Container.h (Container::childEvent): New method. * Container.cc (Container::childEvent): Likewise. Propagate mouse tracking status to child widgets. * BaseControl.cc (BaseControl::eventFilter): Handle mouse move events and call figure's appropriate callback. * Canvas.h (Canvas::updateCurrentPoint): New method. * Canvas.cc (Canvas::updateCurrentPoint): Likewise. Update figure and child axes currentpoint property. (Canvas::canvasMouseMoveEvent): Update currentpoint properties and call windowbuttonmotionfcn callback. (Canvas::canvasMousePressEvent): Call updateCurrentPoint. (Canvas::canvasMouseReleaseEvent): Likewise.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 01 Apr 2014 20:57:08 -0400
parents fb96b7f55242
children 6113e0c6920b 709f3a77685d
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc	Sun Mar 30 14:18:43 2014 -0700
+++ b/libgui/graphics/Figure.cc	Tue Apr 01 20:57:08 2014 -0400
@@ -141,6 +141,12 @@
     eventMask |= Canvas::KeyRelease;
   m_container->canvas (m_handle)->setEventMask (eventMask);
 
+  if (! fp.get_windowbuttonmotionfcn ().is_empty ())
+    {
+      m_container->setMouseTracking (true);
+      m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
+    }
+
   connect (this, SIGNAL (asyncUpdate (void)),
            this, SLOT (updateContainer (void)));
 
@@ -302,6 +308,15 @@
       else
         m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
       break;
+    case figure::properties::ID_WINDOWBUTTONMOTIONFCN:
+        {
+          bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
+
+          m_container->setMouseTracking (hasCallback);
+          foreach (QWidget* w, m_container->findChildren<QWidget*> ())
+            { w->setMouseTracking (hasCallback); }
+        }
+      break;
     default:
       break;
     }