From d44b518c070b9b92f7aefca7e7a66c0b67366b62 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 1 Apr 2015 15:32:06 +0000 Subject: Added FL_ZOOM_GESTURE gesture for OS X. Sadly, I have not commited any code in years, and despite the rumour that I was hit by a train, or worse, move on to Qt, here I am, commmiting unwanted code. Hopefully there are equivalents for this on other platforms?! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10656 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index ecf46a66a..86477c1f4 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -951,6 +951,30 @@ static void cocoaMouseWheelHandler(NSEvent *theEvent) // return noErr; } +/* + * Cocoa Magnify Gesture Handler + */ +static void cocoaMagnifyHandler(NSEvent *theEvent) +{ + 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 magnification]*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_ZOOM_GESTURE, window ); + } + fl_unlock_function(); +} + /* * Cocoa Mouse Button Handler */ @@ -2152,6 +2176,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; - (void)rightMouseDragged:(NSEvent *)theEvent; - (void)otherMouseDragged:(NSEvent *)theEvent; - (void)scrollWheel:(NSEvent *)theEvent; +- (void)magnifyWithEvent:(NSEvent *)theEvent; - (void)keyDown:(NSEvent *)theEvent; - (void)keyUp:(NSEvent *)theEvent; - (void)flagsChanged:(NSEvent *)theEvent; @@ -2276,6 +2301,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil; - (void)scrollWheel:(NSEvent *)theEvent { cocoaMouseWheelHandler(theEvent); } +- (void)magnifyWithEvent:(NSEvent *)theEvent { + cocoaMagnifyHandler(theEvent); +} - (void)keyDown:(NSEvent *)theEvent { //NSLog(@"keyDown:%@",[theEvent characters]); fl_lock_function(); -- cgit v1.2.3