Hit-detection via NSApp's -sendEvent:
Hit-detection via NSApp's -sendEvent:
- Subject: Hit-detection via NSApp's -sendEvent:
- From: Keith Blount <email@hidden>
- Date: Fri, 28 Jul 2006 15:31:40 -0700 (PDT)
Hello,
My app has a full screen mode with a tool bar at the
bottom much like the one in iPhoto (or like the Dock
when it is set to hide): if the user places the mouse
at the bottom of the screen, the tool bar pops up;
moving the cursor above 100 pixels from the bottom
causes it to disappear again. Although I looked in to
doing this via tracking rects or via -mouseMoved
events, I eventually decided that the best way of
doing this would be to trap NSMouseMoved events in
-sendEvent: of my NSApplication subclass. I know this
sounds an odd way of doing it, but the problem is that
my app can have other panels shown over the top of the
full screen window that can become key, and the tool
panel should show even if the mouse is dropped to the
bottom of the screen while one of these other panels
has become key.
Anyway, everything works fine until it comes to a
multi-screen set up. Even then, if my program is run
in full screen on the first monitor of a dual screen
set up, everything is fine. The problems occur when my
program is run in full screen on a second or third
screen. In this event, my beta testers inform me, the
tool bottom that should appear at the bottom of the
screen does not. From various tests, we have
established that the problem occurs in my -sendEvent:
subclass code (unfortunately I do not have access to a
dual monitor set up at the moment and so have to rely
on beta testers). This is the relevant code for my hit
testing in my NSApplication subclass:
- (void)sendEvent:(NSEvent *)anEvent
{
SCRMainDocument *mainDocument =
[[NSDocumentController sharedController]
currentDocument];
if ([mainDocument isFullScreen]) // BOOL returned
from mainDocument which works fine
{
if ([anEvent type] == NSMouseMoved &&
NSPointInRect([NSEvent mouseLocation],[[mainDocument
fullScreenWindow] frame]))
{
float cursorHeight = [NSEvent mouseLocation].y;
if (cursorHeight <= 1.0)
[self sendMessageToFullScreenToShowToolsPanel];
else if (cursorHeight > 100.0)
[self sendMessageToFullScreenToHideToolsPanel];
}
}
[super sendEvent:anEvent];
}
Can anybody see why these messages get sent fine when
the full screen window is on the first screen but not
when it is on another screen? I am sure I must be
making a rather stupid mistake in this code, but I
cannot see it.
Many thanks in advance,
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden