differentiate right and left mouse button

This commit is contained in:
chenhuan 2019-11-28 13:43:38 +01:00
parent 3b89560fef
commit 4fda57b6e6
1 changed files with 29 additions and 14 deletions

View File

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