setMousePosition(x,y) when fl_push and fl_release

This commit is contained in:
Shaohua Tong 2019-11-29 14:33:10 +01:00
parent 124275f1a7
commit 5747b8b5fb
1 changed files with 7 additions and 4 deletions

View File

@ -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*/