osx snow leopard - Cannot become the key window after setting the window to a fake full screen on OSX 10.6.8 -


my application had window (def). spawned new window (new). 2 windows can switched window sub menu item or space control.

but if tried set "new" window fake full screen mode on osx 10.6.8, there problem if switched "def" window either menu or space control. cannot "fully" switch "new" window.

     // setting fake full screen window on 10.6.8      nsapplicationpresentationoptions prereqoptions =         nsapplicationpresentationautohidedock |         nsapplicationpresentationautohidemenubar;      [[nsapplication sharedapplication]         setpresentationoptions:prereqoptions];       [[self window] settoolbar:nil];      [[self window] setstylemask:nsborderlesswindowmask];      [[self window] setframe:[[nsscreen mainscreen] frame]                      display:yes]; 

the "fully" means can see "new" brought top of screen, window controller cannot receive notification "nswindowdidbecomekeynotification". furthermore, [nsapp keywindow], can see key window "def". , can see "def" checked in window submenu.

anyone had ever encountered issue?

finally after 2 days investigation, answer goes documentation of nswindow.

there 2 related methods.

  • (bool)canbecomekeywindow return value yes if window can become key window, otherwise, no.

discussion attempts make window key window abandoned if method returns no. nswindow implementation returns yes if window has title bar or resize bar, or no otherwise.

and

canbecomemainwindow indicates whether window can become application’s main window.

  • (bool)canbecomemainwindow return value yes when window can become main window; otherwise, no.

discussion attempts make window main window abandoned if method returns no. nswindow implementation returns yes if window visible, not nspanel object, , has title bar or resize mechanism. otherwise returns no.

so conclusion if window doesn't have title bar or resize bar, default cannot become main , key window. when setting window fake full screen on 10.6.8 [nswindow setstylemask:nsborderlesswindowmask], title bar gong.

to resolve issue, 1 needs override above 2 methods returning yes.


Comments