Changeset 19853

Show
Ignore:
Timestamp:
03/03/07 23:07:15 (2 years ago)
Author:
patrick
Message:

Handle the case when the mouse pointer is within the bounds of a view
when the window containing the view is first opened. The reason this case
requires special handling is because the response to the mouseEntered
event is needed to get proper notification of mouse movements within the
view. As far as I can tell, there is no other way to get a mouseEntered
event without having the user move the mouse outside the window and then
back inside.

This takes care of the last of the known bugs with the Cocoa input windows.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/gadgeteer/gadget/Devices/KeyboardMouseDevice/InputViewCocoa.mm

    r19844 r19853  
    2727#include <gadget/gadgetConfig.h> 
    2828 
     29#import <Foundation/NSString.h> 
    2930#import <AppKit/NSWindow.h> 
    3031#import <AppKit/NSEvent.h> 
     
    108109      [super viewDidMoveToWindow]; 
    109110      [self resetTrackingRect]; 
     111 
     112      // If this view was moved to a new window, determine if the mouse is 
     113      // currently within the bounds of this view. If it is, then we post a 
     114      // fake mouseEntered event to inform this view that the mouse is within 
     115      // it. Without this, the user would have to move the mouse out of the 
     116      // window and back in to get the mouseEntered event to be posted. 
     117      if ( [self window] ) 
     118      { 
     119         const NSPoint mouse_loc = 
     120            [[self window] mouseLocationOutsideOfEventStream]; 
     121         const NSRect bounds = [self bounds]; 
     122 
     123         if ( [self mouse:mouse_loc inRect:bounds] ) 
     124         { 
     125            // XXX: Would it work better to use CGPostMouseEvent() here? 
     126            [self mouseEntered:nil]; 
     127         } 
     128      } 
    110129   } 
    111130