diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-08-05 12:19:35 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-08-05 12:19:42 +0200 |
| commit | 3049e6394a3376f7fff1c8cde19fd7bb1a9252ec (patch) | |
| tree | e51ea3abc1232caac48edfc24e7e54fdf6495bcf /src | |
| parent | 2953db58c75f30912bee6b91fd5ff087bbb8cad5 (diff) | |
#733 partial: Adds rotation gesture event on MacOS
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 8aef33780..f461505ee 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -966,6 +966,32 @@ static void cocoaMagnifyHandler(NSEvent *theEvent) } /* + * Cocoa Rotate Gesture Handler + */ +static void cocoaRotateHandler(NSEvent *theEvent) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + fl_lock_function(); + Fl_Window *window = (Fl_Window*)[(FLWindow*)[theEvent window] getFl_Window]; + if ( !window->shown() ) { + fl_unlock_function(); + return; + } + Fl::first_window(window); + Fl::e_dy = [theEvent rotation]*1000; + if ( Fl::e_dy) { + NSPoint pos = [theEvent locationInWindow]; + pos.y = window->h() - pos.y; + NSUInteger mods = [theEvent modifierFlags]; + mods_to_e_state( mods ); + update_e_xy_and_e_xy_root([theEvent window]); + Fl::handle( FL_ROTATE_GESTURE, window ); + } + fl_unlock_function(); +#endif +} + +/* * Cocoa Mouse Button Handler */ static void cocoaMouseHandler(NSEvent *theEvent) @@ -2439,6 +2465,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil; - (void)magnifyWithEvent:(NSEvent *)theEvent { cocoaMagnifyHandler(theEvent); } +- (void)rotateWithEvent:(NSEvent *)theEvent { + cocoaRotateHandler(theEvent); +} - (void)keyDown:(NSEvent *)theEvent { //NSLog(@"keyDown:%@",[theEvent characters]); fl_lock_function(); |
