* Source/GSToolTips.m: Fixed two issues with tooltips.

(a) locationInView was being converted twice, producing invalid
        coordinates the second time, when using a provider to get the
        tooltips.
        (b) Tooltips were not working if you had two tracking rects next
        to each other in the same view, when moving from one to the
other,
        depending on the order they were processed, one could get the
        enter before the other's exit, thus canceling the timer.
        Patch by Paul Landers <paul.landers@testplant.com>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2014-12-08 15:29:11 +00:00
parent 903a37dd68
commit 92e67217a4
2 changed files with 31 additions and 6 deletions

View file

@ -1,3 +1,15 @@
2014-12-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSToolTips.m: Fixed two issues with tooltips.
(a) locationInView was being converted twice, producing invalid
coordinates the second time, when using a provider to get the
tooltips.
(b) Tooltips were not working if you had two tracking rects next
to each other in the same view, when moving from one to the other,
depending on the order they were processed, one could get the
enter before the other's exit, thus canceling the timer.
Patch by Paul Landers <paul.landers@testplant.com>.
2014-12-08 Fred Kiefer <FredKiefer@gmx.de> 2014-12-08 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSTableView.h, * Headers/AppKit/NSTableView.h,

View file

@ -202,6 +202,7 @@
@interface GSToolTips (Private) @interface GSToolTips (Private)
- (void) _endDisplay; - (void) _endDisplay;
- (void) _endDisplay: (NSTrackingRectTag)tag;
- (void) _timedOut: (NSTimer *)timer; - (void) _timedOut: (NSTimer *)timer;
@end @end
/* /*
@ -217,6 +218,7 @@ typedef NSView* NSViewPtr;
static NSMapTable *viewsMap = 0; static NSMapTable *viewsMap = 0;
static NSTimer *timer = nil; static NSTimer *timer = nil;
static GSToolTips *timedObject = nil; static GSToolTips *timedObject = nil;
static NSTrackingRectTag timedTag = NSNotFound;
// Having a single stored panel for tooltips greatly reduces callback interaction from MS-Windows // Having a single stored panel for tooltips greatly reduces callback interaction from MS-Windows
static GSTTPanel *window = nil; static GSTTPanel *window = nil;
// Prevent Windows callback API from attempting to dismiss tooltip as its in the process of appearing // Prevent Windows callback API from attempting to dismiss tooltip as its in the process of appearing
@ -341,6 +343,7 @@ static BOOL restoreMouseMoved;
[timer invalidate]; [timer invalidate];
timer = nil; timer = nil;
timedObject = nil; timedObject = nil;
timedTag = NSNotFound;
} }
provider = (GSTTProvider*)[theEvent userData]; provider = (GSTTProvider*)[theEvent userData];
@ -348,8 +351,10 @@ static BOOL restoreMouseMoved;
@selector(view:stringForToolTip:point:userData:)] == YES) @selector(view:stringForToolTip:point:userData:)] == YES)
{ {
// From testing on OS X, point is in the view's coordinate system // From testing on OS X, point is in the view's coordinate system
NSPoint p = [view convertPoint: [theEvent locationInWindow] // The locationInWindow has been converted to this in
fromView: nil]; // [NSWindow _checkTrackingRectangles:forEvent:]
NSPoint p = [theEvent locationInWindow];
toolTipString = [[provider object] view: view toolTipString = [[provider object] view: view
stringForToolTip: [theEvent trackingNumber] stringForToolTip: [theEvent trackingNumber]
point: p point: p
@ -367,6 +372,7 @@ static BOOL restoreMouseMoved;
repeats: YES]; repeats: YES];
[[NSRunLoop currentRunLoop] addTimer: timer forMode: NSModalPanelRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSModalPanelRunLoopMode];
timedObject = self; timedObject = self;
timedTag = [theEvent trackingNumber];
if ([[view window] acceptsMouseMovedEvents] == YES) if ([[view window] acceptsMouseMovedEvents] == YES)
{ {
restoreMouseMoved = NO; restoreMouseMoved = NO;
@ -381,7 +387,7 @@ static BOOL restoreMouseMoved;
- (void) mouseExited: (NSEvent *)theEvent - (void) mouseExited: (NSEvent *)theEvent
{ {
[self _endDisplay]; [self _endDisplay:[theEvent trackingNumber]];
} }
- (void) mouseDown: (NSEvent *)theEvent - (void) mouseDown: (NSEvent *)theEvent
@ -533,6 +539,11 @@ static BOOL restoreMouseMoved;
@implementation GSToolTips (Private) @implementation GSToolTips (Private)
- (void) _endDisplay - (void) _endDisplay
{
[self _endDisplay:NSNotFound];
}
- (void) _endDisplay: (NSTrackingRectTag)tag
{ {
if (isOpening) if (isOpening)
return; return;
@ -540,10 +551,10 @@ static BOOL restoreMouseMoved;
{ {
[NSWindow _setToolTipVisible: nil]; [NSWindow _setToolTipVisible: nil];
} }
/* If there is currently a timer running for this object, /* If there is currently a timer running for this object and it is the target tag,
* cancel it. * cancel it. Always remove if the target tag is NSNotFound
*/ */
if (timer != nil && timedObject == self) if (timer != nil && timedObject == self && (timedTag == tag || tag == NSNotFound))
{ {
if ([timer isValid]) if ([timer isValid])
{ {
@ -551,6 +562,7 @@ static BOOL restoreMouseMoved;
} }
timer = nil; timer = nil;
timedObject = nil; timedObject = nil;
timedTag = NSNotFound;
} }
if (window != nil) if (window != nil)
{ {
@ -595,6 +607,7 @@ static BOOL restoreMouseMoved;
} }
timer = nil; timer = nil;
timedObject = nil; timedObject = nil;
timedTag = NSNotFound;
} }
if ([window isVisible]) if ([window isVisible])