diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2015-04-01 15:32:06 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2015-04-01 15:32:06 +0000 |
| commit | d44b518c070b9b92f7aefca7e7a66c0b67366b62 (patch) | |
| tree | 55670af4e7b035d7533fbd64590e96d3b8e0fb62 /src | |
| parent | b712d85d280e17ee24f728ada654dbec2641f8e9 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 28 |
1 files changed, 28 insertions, 0 deletions
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 @@ -952,6 +952,30 @@ static void cocoaMouseWheelHandler(NSEvent *theEvent) } /* + * 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 */ static void cocoaMouseHandler(NSEvent *theEvent) @@ -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(); |
