mirror of
https://github.com/fltk/fltk.git
synced 2026-05-21 14:31:40 +08:00
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
This commit is contained in:
+6
-1
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user