From 7e2166808c03bc86fac2b973f2d8651b101fbe72 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Thu, 5 Dec 2019 14:11:29 +0100 Subject: [PATCH] fix range of x,y in windowsWidth and windowsHeight --- src/GUI_Window.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 9f8730a..0c6c6c7 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -11,10 +11,10 @@ auto GUI_Window::handle(int e) -> int { case FL_PUSH: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Down"); @@ -31,10 +31,10 @@ auto GUI_Window::handle(int e) -> int { case FL_RELEASE: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Up"); @@ -50,10 +50,10 @@ auto GUI_Window::handle(int e) -> int { case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); this->child(3)->label(position_to_string(x,y)); if (Fl::event_button() == FL_LEFT_MOUSE) { @@ -72,10 +72,10 @@ auto GUI_Window::handle(int e) -> int { case FL_MOVE: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); vkvm::callEvent(vkvm::EventType::MouseMove); this->child(2)->label("Event:Mouse Move");