cocoa - Why NSWindow without styleMask:NSTitledWindowMask can not be keyWindow? -


problem: have 1 window mainwindow , childwindow added mainwindow. childwindow kind of windowext class. class define catch method call [nswindow becomekeywindow] must called after [childwindow makekeywindow]. if create childwindow , try make keywindow on next way:

windowext *childwindow = [[windowext alloc] initwithcontentrect:addedwindowrect                            stylemask:nsborderlesswindowmask | nstitledwindowmask                              backing:nsbackingstorebuffered                                 defer:no]; [mainwindow addchildwindow:childwindow ordered:nswindowabove]; [childwindow makekeywindow]; 

method [windowext becomekeywindow] childwindow called - fine, childwindowbecome keywindow.

but if create childwindow as

windowext *childwindow = [[windowext alloc] initwithcontentrect:addedwindowrect stylemask:nsborderlesswindowmask  backing:nsbackingstorebuffered defer:no]; [mainwindow addchildwindow:childwindow ordered:nswindowabove]; [childwindow makekeywindow]; 

without nstitledwindowmask, [windowext becomekeywindow] childwindow never called - childwindow doesn't become keywindow.

that’s cocoa design decision: windows without title or resize bar cannot become key window default.

if want titleless window able become key window, need create subclass of nswindow , override -canbecomekeywindow follows:

- (bool)canbecomekeywindow {     return yes; } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -