Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Implemented Cocoa mouse wheel events

  • Loading branch information
slouken committed Jul 29, 2006
1 parent 3fce07c commit 04ad26bd54962b7f6b25a907a0198c850fc88d51
Showing with 13 additions and 16 deletions.
  1. +2 −2 include/SDL_events.h
  2. +1 −0 src/video/cocoa/SDL_cocoawindow.h
  3. +9 −13 src/video/cocoa/SDL_cocoawindow.m
  4. +1 −1 test/common.c
@@ -60,11 +60,11 @@ typedef enum
SDL_WINDOWEVENT, /**< Window state change */
SDL_KEYDOWN, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */
SDL_TEXTINPUT, /**< Keyboard text input */
SDL_TEXTINPUT, /**< Keyboard text input */
SDL_MOUSEMOTION, /**< Mouse moved */
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
SDL_MOUSEBUTTONUP, /**< Mouse button released */
SDL_MOUSEWHEEL, /**< Mouse wheel motion */
SDL_MOUSEWHEEL, /**< Mouse wheel motion */
SDL_JOYAXISMOTION, /**< Joystick axis motion */
SDL_JOYBALLMOTION, /**< Joystick trackball motion */
SDL_JOYHATMOTION, /**< Joystick hat position change */
@@ -54,6 +54,7 @@ typedef struct SDL_WindowData SDL_WindowData;
-(void) rightMouseUp:(NSEvent *) theEvent;
-(void) otherMouseUp:(NSEvent *) theEvent;
-(void) mouseMoved:(NSEvent *) theEvent;
-(void) mouseDragged:(NSEvent *) theEvent;
-(void) scrollWheel:(NSEvent *) theEvent;
-(void) keyDown:(NSEvent *) theEvent;
-(void) keyUp:(NSEvent *) theEvent;
@@ -208,26 +208,22 @@ - (void)mouseMoved:(NSEvent *)theEvent
}

point = [NSEvent mouseLocation];
if (point.x < rect.origin.x ||
point.x > (rect.origin.x + rect.size.width) ||
point.y < rect.origin.y ||
point.y > (rect.origin.y + rect.size.height)) {
if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
}
} else {
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
}
}
point.x = point.x - rect.origin.x;
point.y = rect.size.height - (point.y - rect.origin.y);
SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y);
}

- (void)mouseDragged:(NSEvent *)theEvent
{
[self mouseMoved:theEvent];
}

- (void)scrollWheel:(NSEvent *)theEvent
{
fprintf(stderr, "scrollWheel\n");
int index;

index = _data->videodata->mouse;
SDL_SendMouseWheel(index, (int)([theEvent deltaY]+0.9f));
}

- (void)keyDown:(NSEvent *)theEvent
@@ -827,7 +827,7 @@ PrintEvent(SDL_Event * event)
case SDL_MOUSEWHEEL:
fprintf(stderr, "Mouse %d: wheel scrolled %d in window %d",
event->wheel.which, event->wheel.motion,
event->button.windowID);
event->wheel.windowID);
break;
case SDL_JOYBALLMOTION:
fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",

0 comments on commit 04ad26b

Please sign in to comment.