Author: paullanders
Date: Fri Dec  5 20:01:46 2014
New Revision: 38235

URL: http://svn.gna.org/viewcvs/gnustep?rev=38235&view=rev
Log:
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.

Modified:
    libs/gui/branches/gnustep_testplant_branch/Source/GSToolTips.m

Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSToolTips.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSToolTips.m?rev=38235&r1=38234&r2=38235&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSToolTips.m      
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSToolTips.m      Fri Dec 
 5 20:01:46 2014
@@ -202,6 +202,7 @@
 
 @interface     GSToolTips (Private)
 - (void) _endDisplay;
+- (void) _endDisplay:(NSTrackingRectTag)tag;
 - (void) _timedOut: (NSTimer *)timer;
 @end
 /*
@@ -217,6 +218,7 @@
 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 @@
       [timer invalidate];
       timer = nil;
       timedObject = nil;
+      timedTag = NSNotFound;
     }
 
   provider = (GSTTProvider*)[theEvent userData];
@@ -348,8 +351,9 @@
     @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 +371,7 @@
                                           repeats: YES];
   [[NSRunLoop currentRunLoop] addTimer: timer forMode: 
NSModalPanelRunLoopMode];
   timedObject = self;
+  timedTag = [theEvent trackingNumber];
   if ([[view window] acceptsMouseMovedEvents] == YES)
     {
       restoreMouseMoved = NO;
@@ -381,7 +386,7 @@
 
 - (void) mouseExited: (NSEvent *)theEvent
 {
-  [self _endDisplay];
+  [self _endDisplay:[theEvent trackingNumber]];
 }
 
 - (void) mouseDown: (NSEvent *)theEvent
@@ -534,16 +539,21 @@
 
 - (void) _endDisplay
 {
+  [self _endDisplay:NSNotFound];
+}
+
+- (void) _endDisplay:(NSTrackingRectTag)tag
+{
   if (isOpening)
     return;
   if ([NSWindow _toolTipVisible] == self)
     {
       [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 +561,7 @@
        }
       timer = nil;
       timedObject = nil;
+      timedTag = NSNotFound;
     }
   if (window != nil)
     {
@@ -595,6 +606,7 @@
        }
       timer = nil;
       timedObject = nil;
+      timedTag = NSNotFound;
     }
 
   if ([window isVisible])


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to