Detect correctly if mouse is inside or outside the Display on

creation and resize.
This commit is contained in:
kappaOne 2013-02-03 18:58:00 +00:00
parent c328463776
commit f6a2bc8327
2 changed files with 14 additions and 4 deletions

View File

@ -153,8 +153,6 @@ final class MacOSXDisplay implements DisplayImplementation {
}
native_mode = nIsNativeMode(peer_handle);
mouseInsideWindow = true;
updateNativeCursor = true;
if (!native_mode) {
robot = AWTUtil.createRobot(canvas);

View File

@ -342,11 +342,23 @@ static NSAutoreleasePool *pool;
owner:self
userInfo:nil];
[self addTrackingArea:_trackingArea];
// since nstrackingarea's don't know if mouse is inside or outside on creation
// manually detect this and send a fake mouse entered/exited message
NSPoint mouseLocation = [[self window] mouseLocationOutsideOfEventStream];
mouseLocation = [self convertPoint:mouseLocation fromView:nil];
if (NSPointInRect(mouseLocation, [self bounds])) {
[self mouseEntered: nil];
}
else {
[self mouseExited: nil];
}
}
-(void)mouseEntered:(NSEvent *)event {
JNIEnv *env = attachCurrentThread();
if (env == nil || event == nil || _parent == nil || _parent->jdisplay == nil) {
if (env == nil || _parent == nil || _parent->jdisplay == nil) {
return;
}
@ -357,7 +369,7 @@ static NSAutoreleasePool *pool;
-(void)mouseExited:(NSEvent *)event {
JNIEnv *env = attachCurrentThread();
if (env == nil || event == nil || _parent == nil || _parent->jdisplay == nil) {
if (env == nil || _parent == nil || _parent->jdisplay == nil) {
return;
}