]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas GUI: send mouseleave after mouseup outside original window
authorThomas Geymayer <tomgey@gmail.com>
Sat, 29 Jun 2013 12:35:56 +0000 (14:35 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Sat, 29 Jun 2013 12:36:32 +0000 (14:36 +0200)
src/Canvas/gui_mgr.cxx

index cfee29c0747a1cf3419cae75566320f1693a2b90..b1a58eea6a1fd0c1330aee630b496023a27bce83 100644 (file)
@@ -437,11 +437,24 @@ bool GUIMgr::handleMouse(const osgGA::GUIEventAdapter& ea)
       break;
     }
     case osgGA::GUIEventAdapter::RELEASE:
-      target_window = _last_push.lock();
-      _last_push.reset();
+    {
       event->type = sc::Event::MOUSE_UP;
-      break;
 
+      canvas::WindowPtr last_push = _last_push.lock();
+      _last_push.reset();
+
+      if( last_push && last_push != target_window )
+      {
+        // Leave old window
+        sc::MouseEventPtr leave_event( new sc::MouseEvent(*event) );
+        leave_event->type = sc::Event::MOUSE_LEAVE;
+        leave_event->client_pos -= toOsg(last_push->getPosition());
+        leave_event->local_pos = leave_event->client_pos;
+
+        last_push->handleEvent(leave_event);
+      }
+      break;
+    }
     case osgGA::GUIEventAdapter::DRAG:
       target_window = _last_push.lock();
       event->type = sc::Event::DRAG;