differentiate right and left mouse button

This commit is contained in:
chenhuan 2019-11-28 13:43:38 +01:00
parent 3b89560fef
commit 4fda57b6e6

View File

@ -7,30 +7,45 @@ auto GUI_Window::handle(int e) -> int {
/*Mousebutton*/ /*Mousebutton*/
case FL_PUSH: case FL_PUSH:
if (Fl::event_button() == FL_LEFT_MOUSE) { 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) { } 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 { } 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; return 1;
/*Mousebutton and movement*/ /*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: case FL_DRAG:
x = Fl::event_x(); x = Fl::event_x();
y = Fl::event_y(); y = Fl::event_y();
vkvm::setMousePosition(x,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)); 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); vkvm::callEvent(vkvm::EventType::MouseMove);
return 1; return 1;
/*Mousemovement*/ /*Mousemovement*/