Merge pull request #9778 from marcelofg55/2.1
[2.1] Fix Right-Click (Ctrl-Click) on OS X
This commit is contained in:
commit
71a51adc12
|
@ -109,6 +109,7 @@ static int mouse_y = 0;
|
||||||
static int prev_mouse_x = 0;
|
static int prev_mouse_x = 0;
|
||||||
static int prev_mouse_y = 0;
|
static int prev_mouse_y = 0;
|
||||||
static int button_mask = 0;
|
static int button_mask = 0;
|
||||||
|
static bool mouse_down_control = false;
|
||||||
|
|
||||||
@interface GodotApplication : NSApplication
|
@interface GodotApplication : NSApplication
|
||||||
@end
|
@end
|
||||||
|
@ -316,28 +317,39 @@ static int button_mask = 0;
|
||||||
//setModeCursor(window, window->cursorMode);
|
//setModeCursor(window, window->cursorMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)event {
|
static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
|
||||||
//print_line("mouse down:");
|
if (pressed) {
|
||||||
button_mask |= BUTTON_MASK_LEFT;
|
button_mask |= mask;
|
||||||
|
} else {
|
||||||
|
button_mask &= ~mask;
|
||||||
|
}
|
||||||
|
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
|
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
ev.type = InputEvent::MOUSE_BUTTON;
|
||||||
ev.mouse_button.button_index = BUTTON_LEFT;
|
ev.mouse_button.button_index = index;
|
||||||
ev.mouse_button.pressed = true;
|
ev.mouse_button.pressed = pressed;
|
||||||
ev.mouse_button.x = mouse_x;
|
ev.mouse_button.x = mouse_x;
|
||||||
ev.mouse_button.y = mouse_y;
|
ev.mouse_button.y = mouse_y;
|
||||||
ev.mouse_button.global_x = mouse_x;
|
ev.mouse_button.global_x = mouse_x;
|
||||||
ev.mouse_button.global_y = mouse_y;
|
ev.mouse_button.global_y = mouse_y;
|
||||||
ev.mouse_button.button_mask = button_mask;
|
ev.mouse_button.button_mask = button_mask;
|
||||||
ev.mouse_button.doubleclick = [event clickCount] == 2;
|
if (index == BUTTON_LEFT && pressed) {
|
||||||
|
ev.mouse_button.doubleclick = [event clickCount] == 2;
|
||||||
|
}
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
OS_OSX::singleton->push_input(ev);
|
||||||
_glfwInputMouseClick(window,
|
}
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
|
||||||
GLFW_PRESS,
|
- (void)mouseDown:(NSEvent *)event {
|
||||||
translateFlags([event modifierFlags]));
|
if (([event modifierFlags] & NSControlKeyMask)) {
|
||||||
*/
|
mouse_down_control = true;
|
||||||
|
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
|
||||||
|
} else {
|
||||||
|
mouse_down_control = false;
|
||||||
|
_mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDragged:(NSEvent *)event {
|
- (void)mouseDragged:(NSEvent *)event {
|
||||||
|
@ -345,25 +357,11 @@ static int button_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseUp:(NSEvent *)event {
|
- (void)mouseUp:(NSEvent *)event {
|
||||||
button_mask &= ~BUTTON_MASK_LEFT;
|
if (mouse_down_control) {
|
||||||
InputEvent ev;
|
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
} else {
|
||||||
ev.mouse_button.button_index = BUTTON_LEFT;
|
_mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, false);
|
||||||
ev.mouse_button.pressed = false;
|
}
|
||||||
ev.mouse_button.x = mouse_x;
|
|
||||||
ev.mouse_button.y = mouse_y;
|
|
||||||
ev.mouse_button.global_x = mouse_x;
|
|
||||||
ev.mouse_button.global_y = mouse_y;
|
|
||||||
ev.mouse_button.button_mask = button_mask;
|
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
_glfwInputMouseClick(window,
|
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
|
||||||
GLFW_RELEASE,
|
|
||||||
translateFlags([event modifierFlags]));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)event {
|
- (void)mouseMoved:(NSEvent *)event {
|
||||||
|
@ -401,26 +399,7 @@ static int button_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDown:(NSEvent *)event {
|
- (void)rightMouseDown:(NSEvent *)event {
|
||||||
|
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
|
||||||
button_mask |= BUTTON_MASK_RIGHT;
|
|
||||||
InputEvent ev;
|
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
|
||||||
ev.mouse_button.button_index = BUTTON_RIGHT;
|
|
||||||
ev.mouse_button.pressed = true;
|
|
||||||
ev.mouse_button.x = mouse_x;
|
|
||||||
ev.mouse_button.y = mouse_y;
|
|
||||||
ev.mouse_button.global_x = mouse_x;
|
|
||||||
ev.mouse_button.global_y = mouse_y;
|
|
||||||
ev.mouse_button.button_mask = button_mask;
|
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
_glfwInputMouseClick(window,
|
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
|
||||||
GLFW_PRESS,
|
|
||||||
translateFlags([event modifierFlags]));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDragged:(NSEvent *)event {
|
- (void)rightMouseDragged:(NSEvent *)event {
|
||||||
|
@ -428,26 +407,7 @@ static int button_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseUp:(NSEvent *)event {
|
- (void)rightMouseUp:(NSEvent *)event {
|
||||||
|
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
|
||||||
button_mask &= ~BUTTON_MASK_RIGHT;
|
|
||||||
InputEvent ev;
|
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
|
||||||
ev.mouse_button.button_index = BUTTON_RIGHT;
|
|
||||||
ev.mouse_button.pressed = false;
|
|
||||||
ev.mouse_button.x = mouse_x;
|
|
||||||
ev.mouse_button.y = mouse_y;
|
|
||||||
ev.mouse_button.global_x = mouse_x;
|
|
||||||
ev.mouse_button.global_y = mouse_y;
|
|
||||||
ev.mouse_button.button_mask = button_mask;
|
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
_glfwInputMouseClick(window,
|
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
|
||||||
GLFW_RELEASE,
|
|
||||||
translateFlags([event modifierFlags]));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDown:(NSEvent *)event {
|
- (void)otherMouseDown:(NSEvent *)event {
|
||||||
|
@ -455,25 +415,7 @@ static int button_mask = 0;
|
||||||
if ((int)[event buttonNumber] != 2)
|
if ((int)[event buttonNumber] != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
button_mask |= BUTTON_MASK_MIDDLE;
|
_mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, true);
|
||||||
InputEvent ev;
|
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
|
||||||
ev.mouse_button.button_index = BUTTON_MIDDLE;
|
|
||||||
ev.mouse_button.pressed = true;
|
|
||||||
ev.mouse_button.x = mouse_x;
|
|
||||||
ev.mouse_button.y = mouse_y;
|
|
||||||
ev.mouse_button.global_x = mouse_x;
|
|
||||||
ev.mouse_button.global_y = mouse_y;
|
|
||||||
ev.mouse_button.button_mask = button_mask;
|
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
_glfwInputMouseClick(window,
|
|
||||||
(int) [event buttonNumber],
|
|
||||||
GLFW_PRESS,
|
|
||||||
translateFlags([event modifierFlags]));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDragged:(NSEvent *)event {
|
- (void)otherMouseDragged:(NSEvent *)event {
|
||||||
|
@ -485,25 +427,7 @@ static int button_mask = 0;
|
||||||
if ((int)[event buttonNumber] != 2)
|
if ((int)[event buttonNumber] != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
button_mask &= ~BUTTON_MASK_MIDDLE;
|
_mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, false);
|
||||||
InputEvent ev;
|
|
||||||
ev.type = InputEvent::MOUSE_BUTTON;
|
|
||||||
ev.mouse_button.button_index = BUTTON_MIDDLE;
|
|
||||||
ev.mouse_button.pressed = false;
|
|
||||||
ev.mouse_button.x = mouse_x;
|
|
||||||
ev.mouse_button.y = mouse_y;
|
|
||||||
ev.mouse_button.global_x = mouse_x;
|
|
||||||
ev.mouse_button.global_y = mouse_y;
|
|
||||||
ev.mouse_button.button_mask = button_mask;
|
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
|
||||||
OS_OSX::singleton->push_input(ev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
_glfwInputMouseClick(window,
|
|
||||||
(int) [event buttonNumber],
|
|
||||||
GLFW_RELEASE,
|
|
||||||
translateFlags([event modifierFlags]));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseExited:(NSEvent *)event {
|
- (void)mouseExited:(NSEvent *)event {
|
||||||
|
|
Loading…
Reference in New Issue