diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 6963d29d5..15ca42b8b 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -124,19 +124,23 @@ void EventHandlerSDL2::pollEvent() case SDL_MOUSEBUTTONUP: { // ToDo: check support of more buttons and double-click + MouseButton b{MouseButton::NONE}; switch(myEvent.button.button) { case SDL_BUTTON_LEFT: - handleMouseButtonEvent(MouseButton::LEFT, myEvent.button.type == SDL_MOUSEBUTTONDOWN, - myEvent.button.x, myEvent.button.y); + b = MouseButton::LEFT; break; case SDL_BUTTON_RIGHT: - handleMouseButtonEvent(MouseButton::RIGHT, myEvent.button.type == SDL_MOUSEBUTTONDOWN, - myEvent.button.x, myEvent.button.y); + b = MouseButton::RIGHT; + break; + case SDL_BUTTON_MIDDLE: + b = MouseButton::MIDDLE; break; default: break; } + handleMouseButtonEvent(b, myEvent.button.type == SDL_MOUSEBUTTONDOWN, + myEvent.button.x, myEvent.button.y); break; } diff --git a/src/emucore/EventHandlerConstants.hxx b/src/emucore/EventHandlerConstants.hxx index 110191a2e..8ed0801cf 100644 --- a/src/emucore/EventHandlerConstants.hxx +++ b/src/emucore/EventHandlerConstants.hxx @@ -37,6 +37,7 @@ enum class EventHandlerState { enum class MouseButton { LEFT, RIGHT, + MIDDLE, WHEELDOWN, WHEELUP, NONE diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index cdca03d44..a6bfb6356 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -256,6 +256,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed, { case MouseButton::LEFT: case MouseButton::RIGHT: + case MouseButton::MIDDLE: if(pressed) { // If more than two clicks have been recorded, we start over @@ -266,7 +267,13 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed, myLastClick.count = 0; } - if(myLastClick.count && (myTime < myLastClick.time + _DOUBLE_CLICK_DELAY) + if(b == MouseButton::MIDDLE) + { + // Middle mouse button emulates lef mouse button double click + myLastClick.count = 2; + b = MouseButton::LEFT; + } + else if(myLastClick.count && (myTime < myLastClick.time + _DOUBLE_CLICK_DELAY) && std::abs(myLastClick.x - x) < 3 && std::abs(myLastClick.y - y) < 3) {