fix range of x,y in windowsWidth and windowsHeight
This commit is contained in:
parent
44658873a3
commit
9d8b954f71
@ -3,11 +3,18 @@
|
|||||||
|
|
||||||
/*Function to handle the input*/
|
/*Function to handle the input*/
|
||||||
auto GUI_Window::handle(int e) -> int {
|
auto GUI_Window::handle(int e) -> int {
|
||||||
|
int windowsWidth = vkvm::getWidth();
|
||||||
|
int windowsHeight = vkvm::getHeight();
|
||||||
|
|
||||||
switch (e) {
|
switch (e) {
|
||||||
/*Mousebutton*/
|
/*Mousebutton*/
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
x = Fl::event_x();
|
x = Fl::event_x();
|
||||||
y = Fl::event_y();
|
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;
|
||||||
vkvm::setMousePosition(x,y);
|
vkvm::setMousePosition(x,y);
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||||
this->child(2)->label("Event:Mouse Left Down");
|
this->child(2)->label("Event:Mouse Left Down");
|
||||||
@ -24,6 +31,10 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
case FL_RELEASE:
|
case FL_RELEASE:
|
||||||
x = Fl::event_x();
|
x = Fl::event_x();
|
||||||
y = Fl::event_y();
|
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;
|
||||||
vkvm::setMousePosition(x,y);
|
vkvm::setMousePosition(x,y);
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||||
this->child(2)->label("Event:Mouse Left Up");
|
this->child(2)->label("Event:Mouse Left Up");
|
||||||
@ -39,19 +50,20 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
case FL_DRAG:
|
case FL_DRAG:
|
||||||
x = Fl::event_x();
|
x = Fl::event_x();
|
||||||
y = Fl::event_y();
|
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;
|
||||||
vkvm::setMousePosition(x,y);
|
vkvm::setMousePosition(x,y);
|
||||||
this->child(3)->label(position_to_string(x,y));
|
this->child(3)->label(position_to_string(x,y));
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||||
this->child(2)->label("Event:Mouse Left Drag");
|
this->child(2)->label("Event:Mouse Left Drag");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseLeftDown);
|
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
||||||
this->child(2)->label("Event:Mouse Right Drag");
|
this->child(2)->label("Event:Mouse Right Drag");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseRightDown);
|
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
} else {
|
} else {
|
||||||
this->child(2)->label("Event:Mouse Middle Drag");
|
this->child(2)->label("Event:Mouse Middle Drag");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMiddleDown);
|
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +72,10 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
case FL_MOVE:
|
case FL_MOVE:
|
||||||
x = Fl::event_x();
|
x = Fl::event_x();
|
||||||
y = Fl::event_y();
|
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;
|
||||||
vkvm::setMousePosition(x,y);
|
vkvm::setMousePosition(x,y);
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
this->child(2)->label("Event:Mouse Move");
|
this->child(2)->label("Event:Mouse Move");
|
||||||
|
Loading…
Reference in New Issue
Block a user