cocoa - Make NSView in NSPanel first responder without key window status -
is possible give nsview inside nspanel first responder status without giving nspanel key window status (making main application window resign key)?
thanks.
well, ended figuring 1 out, took lot of research i'll post details here in case else runs same problem. first of all, few basics:
- it's impossible have 2 windows key @ same time
- it's possible fake window thinking it's key overriding
-iskeywindow
won't give views contained in window first responder status.
my scenario:
i added child window containing nstableview
main application window (the reason irrelavant). child window nspanel
nsborderlesswindowmask
. wanted give nstableview
first responder status without making panel key window because took away focus main window (and whole point of child window illusion make child window part of main window).
the first thing tried fooling table view thinking inside key window overriding iskeywindow
return yes
. made table view draw if first responder, still did not give first responder status.
the solution:
so default, nsborderlesswindowmask not allow window become key. make table view first responder, window had key overrode canbecomekeywindow
in borderless window subclass return yes
. this, of course, took away key status main window, 1 of things wanted avoid. fix this, subclassed main window , overrode following methods:
- (bool)ismainwindow { return yes; } - (bool)iskeywindow { return ([nsapp isactive]) ? yes : [super iskeywindow]; }
this subclass checks if application active, , if is, returns yes
no matter window active in application, main window behave if still key. sort of gives illusion can have multiple windows key @ same time , enables shift key window status window without losing on main window. hope helps!
Comments
Post a Comment