aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2014-07-15 11:06:00 +1000
committerNeil Hodgson <nyamatongwe@gmail.com>2014-07-15 11:06:00 +1000
commit7b7865ca3062d57ebe990468a9275180f0d60569 (patch)
tree2ff401b77f6fa2dfb54b4adc049dae07c96dd816
parent5cae5d81ac08a7c189798ce976a596a9d0a42e8f (diff)
downloadscintilla-mirror-7b7865ca3062d57ebe990468a9275180f0d60569.tar.gz
Switch from tracking rectangle to tracking area. This is the more recent Cocoa API and
allows detection of mouse movement when the view does not have the focus which is needed for dwell events.
-rw-r--r--cocoa/ScintillaView.h2
-rw-r--r--cocoa/ScintillaView.mm32
2 files changed, 23 insertions, 11 deletions
diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h
index 419c2f28f..102bf3b60 100644
--- a/cocoa/ScintillaView.h
+++ b/cocoa/ScintillaView.h
@@ -75,7 +75,7 @@ extern NSString *const SCIUpdateUINotification;
@private
ScintillaView* mOwner;
NSCursor* mCurrentCursor;
- NSTrackingRectTag mCurrentTrackingRect;
+ NSTrackingArea *trackingArea;
// Set when we are in composition mode and partial input is displayed.
NSRange mMarkedTextRange;
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index 2ca7ed6bc..020fddeae 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -165,7 +165,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)
{
// Some initialization for our view.
mCurrentCursor = [[NSCursor arrowCursor] retain];
- mCurrentTrackingRect = 0;
+ trackingArea = nil;
mMarkedTextRange = NSMakeRange(NSNotFound, 0);
[self registerForDraggedTypes: [NSArray arrayWithObjects:
@@ -178,19 +178,31 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)
//--------------------------------------------------------------------------------------------------
/**
- * When the view is resized we need to update our tracking rectangle and let the backend know.
+ * When the view is resized or scrolled we need to update our tracking area.
+ */
+- (void) updateTrackingAreas
+{
+ if (trackingArea)
+ [self removeTrackingArea:trackingArea];
+
+ int opts = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
+ trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
+ options:opts
+ owner:self
+ userInfo:nil];
+ [self addTrackingArea: trackingArea];
+ [super updateTrackingAreas];
+}
+
+//--------------------------------------------------------------------------------------------------
+
+/**
+ * When the view is resized we need to let the backend know.
*/
- (void) setFrame: (NSRect) frame
{
[super setFrame: frame];
-
- // Make the content also a tracking rectangle for mouse events.
- if (mCurrentTrackingRect != 0)
- [self removeTrackingRect: mCurrentTrackingRect];
- mCurrentTrackingRect = [self addTrackingRect: [self bounds]
- owner: self
- userData: nil
- assumeInside: YES];
+
mOwner.backend->Resize();
}