mirror of
https://github.com/joel16/SDL2.git
synced 2024-12-13 22:38:34 +00:00
Implemented Cocoa mouse wheel events
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402003
This commit is contained in:
parent
c8d7322dc6
commit
be01a86b9e
@ -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 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||
}
|
||||
|
||||
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",
|
||||
|
Loading…
Reference in New Issue
Block a user