Use OS-provided click counts on macOS and iOS for mouse press and release events.

This commit is contained in:
Alex Szpakowski
2016-09-24 18:46:34 -03:00
parent bac5394127
commit 450fa8cdf9
4 changed files with 36 additions and 15 deletions

View File

@@ -823,6 +823,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (void)mouseDown:(NSEvent *)theEvent
{
int button;
int clicks;
/* Ignore events that aren't inside the client area (i.e. title bar.) */
if ([theEvent window]) {
@@ -858,7 +859,9 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
button = (int) [theEvent buttonNumber] + 1;
break;
}
SDL_SendMouseButton(_data->window, 0, SDL_PRESSED, button);
clicks = (int) [theEvent clickCount];
SDL_SendMouseButtonClicks(_data->window, 0, SDL_PRESSED, button, clicks);
}
- (void)rightMouseDown:(NSEvent *)theEvent
@@ -874,6 +877,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (void)mouseUp:(NSEvent *)theEvent
{
int button;
int clicks;
if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
@@ -899,7 +903,9 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
button = (int) [theEvent buttonNumber] + 1;
break;
}
SDL_SendMouseButton(_data->window, 0, SDL_RELEASED, button);
clicks = (int) [theEvent clickCount];
SDL_SendMouseButtonClicks(_data->window, 0, SDL_RELEASED, button, clicks);
}
- (void)rightMouseUp:(NSEvent *)theEvent
@@ -1264,7 +1270,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
}
}
[nswindow setContentView: contentView];
[nswindow setContentView:contentView];
[contentView release];
/* Allow files and folders to be dragged onto the window by users */

View File

@@ -143,12 +143,13 @@
if (!firstFingerDown) {
CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
int clicks = (int) touch.tapCount;
/* send mouse moved event */
SDL_SendMouseMotion(sdlwindow, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
/* send mouse down event */
SDL_SendMouseButton(sdlwindow, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
SDL_SendMouseButtonClicks(sdlwindow, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT, clicks);
firstFingerDown = touch;
}
@@ -166,7 +167,8 @@
if (touch == firstFingerDown) {
/* send mouse up */
SDL_SendMouseButton(sdlwindow, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
int clicks = (int) touch.tapCount;
SDL_SendMouseButtonClicks(sdlwindow, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT, clicks);
firstFingerDown = nil;
}