Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
so here's a fun one that i've been trying to solve for a few weeks now...

2 window objects: Main Window and Full Screen Window... when Full Screen Window is up, the mouse cursor should hide until moved, then become invisible again after 1 second if the NSCursor has not moved.

everything work fine ONLY IF the user first clicks on the full screen window (when it's visible) to activate the process... i've tried lots: if ([FullScreenWindow isVisible]) activate the process, if it's not visible activate the process, etc, etc, etc... i've seen this done in countless apps but i just can't get it...

the small project code is attached... if someone can take a look and let me know what i'm doing wrong this that would be great...
 

Attachments

  • FullScreenMouseTest.zip
    30.9 KB · Views: 123

kpua

macrumors 6502
Jul 25, 2006
294
0
It seems like moving the call to -setAcceptsMouseMovedEvents: outside -awakeFromNib makes it work. You may want to use a delegate to set up your timer in -windowDidBecomeKey: or you can listen for NSWindowDidBecomeKeyNotification.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
It seems like moving the call to -setAcceptsMouseMovedEvents: outside -awakeFromNib makes it work.

i'm not sure i follow what you mean here... you mean get rid of the awakeFromNib method and write [self setAcceptsMouseMovedEvents:YES]; in some other method?
 

kpua

macrumors 6502
Jul 25, 2006
294
0
I tried it both at the end of your FullScreenMode: method and a quick and dirty override of -makeKeyAndOrderFront: (after calling super), which isn't recommended, but the delegate method should be roughly equivalent.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
I tried it both at the end of your FullScreenMode: method and a quick and dirty override of -makeKeyAndOrderFront: (after calling super), which isn't recommended, but the delegate method should be roughly equivalent.

christ... that was WELL dumb of me... i sware i tried this and a bunch of other things before but it seems to work perfectly as you say by removing the awakeFromNib method from the FullScreenWindow class and just change the app controller to look like this:

Code:
- (IBAction)WindowMode:(id)sender
	{
	[FullScreenWindow orderOut:nil];
	SetSystemUIMode(kUIModeNormal, 0);
	[MainWindow makeKeyAndOrderFront:nil];
	[COLOR="RoyalBlue"][NSCursor setHiddenUntilMouseMoves:NO][/COLOR];
	}

- (IBAction)FullScreenMode:(id)sender
	{
	[MainWindow orderOut:nil];
	SetSystemUIMode(kUIModeAllHidden, 0);
	[FullScreenWindow makeKeyAndOrderFront:nil];
	[FullScreenWindow setFrame:[[FullScreenWindow screen] visibleFrame] display:YES];
	SetSystemUIMode(kUIModeAllSuppressed, 0);
[COLOR="RoyalBlue"]	[FullScreenWindow setAcceptsMouseMovedEvents:YES];
	[NSCursor setHiddenUntilMouseMoves:YES];[/COLOR]
	}

thanks for the help :eek:
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
... You may want to use a delegate to set up your timer in -windowDidBecomeKey: or you can listen for NSWindowDidBecomeKeyNotification.

i've realized that while the above code alterations now work, whenever i switch back to the main window it's still timing down to the last [NSCursor setHiddenUntilMouseMoves:YES]; from the FullScreen class and will once more hide the cursor when the mode switches from full screen to window mode, even though the IBAction for the main Window has [NSCursor setHiddenUntilMouseMoves:NO]; as apart of it's method... i can't seem to override the last timer that runs when switching from full screen to main window. i don't know how to invalidate the timer from the IBAction Window Mode method in the app controller class...

i've tried writing:
Code:
- (void)hideMouse:(NSTimer *)theTimer
	{
	if ([self isVisible]) // or if self isKeyWindow
		{
		[NSCursor setHiddenUntilMouseMoves:YES];
		timer = nil;
		}
	}
but that just seems to crash the app... ??

finally, i'm not following really your suggestion to including NSNotification here... when i set it up it only works once, since the posting a notification with the appcontroller's FullScreen IBAction is only triggered once, which is why i have been using the mouseMoved event... unless i've misunderstood what you mean exactly - which is quite possible...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.