summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Enumerations.H7
-rw-r--r--src/Fl_cocoa.mm28
2 files changed, 34 insertions, 1 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index 6419b65a4..da479a327 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -300,7 +300,12 @@ enum Fl_Event { // events
FL_SCREEN_CONFIGURATION_CHANGED = 24,
/** The fullscreen state of the window has changed
*/
- FL_FULLSCREEN = 25
+ FL_FULLSCREEN = 25,
+ /** The user has made a zoom/pinch/magnification gesture.
+ The Fl::event_dy() method can be used to find magnification amount,
+ Fl::event_x() and Fl::event_y() are set as well.
+ */
+ FL_ZOOM_GESTURE = 26
};
/** \name When Conditions */
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();