From 4fda57b6e66f71a25aa63b7779436829e1490ae2 Mon Sep 17 00:00:00 2001 From: chenhuan Date: Thu, 28 Nov 2019 13:43:38 +0100 Subject: [PATCH] differentiate right and left mouse button --- src/GUI_Window.cpp | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index fa4b65d..da0d5f2 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -7,30 +7,45 @@ auto GUI_Window::handle(int e) -> int { /*Mousebutton*/ case FL_PUSH: if (Fl::event_button() == FL_LEFT_MOUSE) { - std::cout << "Mouse:left" << std::endl; + this->child(2)->label("Event:Mouse Left Down"); + vkvm::callEvent(vkvm::EventType::MouseLeftDown); } else if (Fl::event_button() == FL_RIGHT_MOUSE) { - std::cout << "Mouse:right" << std::endl; + this->child(2)->label("Event:Mouse Right Down"); + vkvm::callEvent(vkvm::EventType::MouseRightDown); } else { - std::cout << "Mouse:middle" << std::endl; + this->child(2)->label("Event:Mouse Middle Down"); + vkvm::callEvent(vkvm::EventType::MouseMiddleDown); } - this->child(2)->label("Event:Mouse Button"); - vkvm::callEvent(vkvm::EventType::MouseButton); return 1; /*Mousebutton and movement*/ + case FL_RELEASE: + if (Fl::event_button() == FL_LEFT_MOUSE) { + this->child(2)->label("Event:Mouse Left Up"); + vkvm::callEvent(vkvm::EventType::MouseLeftUp); + } else if (Fl::event_button() == FL_RIGHT_MOUSE) { + this->child(2)->label("Event:Mouse Right Up"); + vkvm::callEvent(vkvm::EventType::MouseRightUp); + } else { + this->child(2)->label("Event:Mouse Middle Up"); + vkvm::callEvent(vkvm::EventType::MouseMiddleUp); + } + return 1; case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); vkvm::setMousePosition(x,y); - if (Fl::event_button() == FL_LEFT_MOUSE) { - std::cout << "Mouse:left" << std::endl; - } else if (Fl::event_button() == FL_RIGHT_MOUSE) { - std::cout << "Mouse:right" << std::endl; - } else { - std::cout << "Mouse:middle" << std::endl; - } - this->child(2)->label("Event:Mouse Drag"); this->child(3)->label(position_to_string(x,y)); - vkvm::callEvent(vkvm::EventType::MouseButton); + 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::MouseMove); return 1; /*Mousemovement*/