From 5747b8b5fb4945bc7e24b3292fbfccf806c048c2 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Fri, 29 Nov 2019 14:33:10 +0100 Subject: [PATCH] setMousePosition(x,y) when fl_push and fl_release --- src/GUI_Window.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index da0d5f2..9e931c3 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -6,6 +6,9 @@ auto GUI_Window::handle(int e) -> int { switch (e) { /*Mousebutton*/ case FL_PUSH: + x = Fl::event_x(); + y = Fl::event_y(); + vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Down"); vkvm::callEvent(vkvm::EventType::MouseLeftDown); @@ -19,6 +22,9 @@ auto GUI_Window::handle(int e) -> int { return 1; /*Mousebutton and movement*/ case FL_RELEASE: + x = Fl::event_x(); + y = Fl::event_y(); + vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Up"); vkvm::callEvent(vkvm::EventType::MouseLeftUp); @@ -37,15 +43,12 @@ auto GUI_Window::handle(int e) -> int { this->child(3)->label(position_to_string(x,y)); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Drag"); - vkvm::callEvent(vkvm::EventType::MouseLeftUp); } else if (Fl::event_button() == FL_RIGHT_MOUSE) { this->child(2)->label("Event:Mouse Right Drag"); - vkvm::callEvent(vkvm::EventType::MouseRightUp); } else { this->child(2)->label("Event:Mouse Middle Drag"); - vkvm::callEvent(vkvm::EventType::MouseMiddleUp); } - vkvm::callEvent(vkvm::EventType::MouseLeftUp); + vkvm::callEvent(vkvm::EventType::MouseLeftDown); vkvm::callEvent(vkvm::EventType::MouseMove); return 1; /*Mousemovement*/