changeset 19800:b38b677c0fa8

pass button number to Qt graphics buttondownfcn callback (bug #41977) * Canvas.cc (button_number): New static function. (Canvas::canvasMousePressEvent): Use it to pass button number to buttondownfcn.
author John W. Eaton <jwe@octave.org>
date Thu, 19 Feb 2015 02:33:05 -0500
parents c040bed12b2e
children a010a65ace1f
files libgui/graphics/Canvas.cc
diffstat 1 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc	Thu Feb 19 02:16:48 2015 -0500
+++ b/libgui/graphics/Canvas.cc	Thu Feb 19 02:33:05 2015 -0500
@@ -408,6 +408,29 @@
     }
 }
 
+static double
+button_number (QMouseEvent *event)
+{
+  double retval = 0;
+
+  switch (event->button ())
+    {
+    case Qt::LeftButton:
+      retval = 1;
+      break;
+
+    case Qt::MidButton:
+      retval = 2;
+      break;
+
+    case Qt::RightButton:
+      retval = 3;
+      break;
+    }
+
+  return retval;
+}
+
 void Canvas::canvasMousePressEvent (QMouseEvent* event)
 {
   gh_manager::auto_lock lock;
@@ -500,11 +523,15 @@
         case NoMode:
           gh_manager::post_set (figObj.get_handle (), "selectiontype",
                                 Utils::figureSelectionType (event), false);
+
           updateCurrentPoint (figObj, obj, event);
+
           gh_manager::post_callback (figObj.get_handle (),
                                      "windowbuttondownfcn");
+
           gh_manager::post_callback (currentObj.get_handle (),
-                                     "buttondownfcn");
+                                     "buttondownfcn", button_number (event));
+
           if (event->button () == Qt::RightButton)
             ContextMenu::executeAt (currentObj.get_properties (),
                                     event->globalPos ());