mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 23:40:38 +00:00
* 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:
parent
903a37dd68
commit
92e67217a4
2 changed files with 31 additions and 6 deletions
|
@ -202,6 +202,7 @@
|
|||
|
||||
@interface GSToolTips (Private)
|
||||
- (void) _endDisplay;
|
||||
- (void) _endDisplay: (NSTrackingRectTag)tag;
|
||||
- (void) _timedOut: (NSTimer *)timer;
|
||||
@end
|
||||
/*
|
||||
|
@ -217,6 +218,7 @@ typedef NSView* NSViewPtr;
|
|||
static NSMapTable *viewsMap = 0;
|
||||
static NSTimer *timer = nil;
|
||||
static GSToolTips *timedObject = nil;
|
||||
static NSTrackingRectTag timedTag = NSNotFound;
|
||||
// Having a single stored panel for tooltips greatly reduces callback interaction from MS-Windows
|
||||
static GSTTPanel *window = nil;
|
||||
// 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 = nil;
|
||||
timedObject = nil;
|
||||
timedTag = NSNotFound;
|
||||
}
|
||||
|
||||
provider = (GSTTProvider*)[theEvent userData];
|
||||
|
@ -348,8 +351,10 @@ static BOOL restoreMouseMoved;
|
|||
@selector(view:stringForToolTip:point:userData:)] == YES)
|
||||
{
|
||||
// From testing on OS X, point is in the view's coordinate system
|
||||
NSPoint p = [view convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
// The locationInWindow has been converted to this in
|
||||
// [NSWindow _checkTrackingRectangles:forEvent:]
|
||||
NSPoint p = [theEvent locationInWindow];
|
||||
|
||||
toolTipString = [[provider object] view: view
|
||||
stringForToolTip: [theEvent trackingNumber]
|
||||
point: p
|
||||
|
@ -367,6 +372,7 @@ static BOOL restoreMouseMoved;
|
|||
repeats: YES];
|
||||
[[NSRunLoop currentRunLoop] addTimer: timer forMode: NSModalPanelRunLoopMode];
|
||||
timedObject = self;
|
||||
timedTag = [theEvent trackingNumber];
|
||||
if ([[view window] acceptsMouseMovedEvents] == YES)
|
||||
{
|
||||
restoreMouseMoved = NO;
|
||||
|
@ -381,7 +387,7 @@ static BOOL restoreMouseMoved;
|
|||
|
||||
- (void) mouseExited: (NSEvent *)theEvent
|
||||
{
|
||||
[self _endDisplay];
|
||||
[self _endDisplay:[theEvent trackingNumber]];
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *)theEvent
|
||||
|
@ -533,6 +539,11 @@ static BOOL restoreMouseMoved;
|
|||
@implementation GSToolTips (Private)
|
||||
|
||||
- (void) _endDisplay
|
||||
{
|
||||
[self _endDisplay:NSNotFound];
|
||||
}
|
||||
|
||||
- (void) _endDisplay: (NSTrackingRectTag)tag
|
||||
{
|
||||
if (isOpening)
|
||||
return;
|
||||
|
@ -540,10 +551,10 @@ static BOOL restoreMouseMoved;
|
|||
{
|
||||
[NSWindow _setToolTipVisible: nil];
|
||||
}
|
||||
/* If there is currently a timer running for this object,
|
||||
* cancel it.
|
||||
/* If there is currently a timer running for this object and it is the target tag,
|
||||
* 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])
|
||||
{
|
||||
|
@ -551,6 +562,7 @@ static BOOL restoreMouseMoved;
|
|||
}
|
||||
timer = nil;
|
||||
timedObject = nil;
|
||||
timedTag = NSNotFound;
|
||||
}
|
||||
if (window != nil)
|
||||
{
|
||||
|
@ -595,6 +607,7 @@ static BOOL restoreMouseMoved;
|
|||
}
|
||||
timer = nil;
|
||||
timedObject = nil;
|
||||
timedTag = NSNotFound;
|
||||
}
|
||||
|
||||
if ([window isVisible])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue