objective c - How To get to know focussed window in cocoa, and how to set it to desired window.? -
i new cocoa mac development, right developing mac app having several server hit after particular time. if hit gets desired data need to show equivalent window , show window using [mywindow showwindow:self] method. shows desired window , set key window visible window mywindow.
each , fine till problem suppose when user start working on window , open several other child window unfortunately show window called , focus of working window transferred other window.
after several searches found can focused window accessing [[nsapplication sharedapplication]keywindow]delegate], applied several condition when , window on key window don't hit server.
but problem not solved. think setting keywindow current working window best option.
please suggest me can , how can forcefully set window key window.
any appreciated. in advance.
if understand question correctly wish bring window forward if receives input server without moving in front of current main or key windows.
the method using, showwindow:
, belongs nswindowcontroller
, both shows window , makes key.
what need @ nswindow
methods managing window levels, orderfront:
et al.
in particular might want use orderwindow:relativeto:
allows place window in front/behind window. example:
[<window> orderwindow:nswindowbelow relativeto:nsapp.keywindow.windownumber];
will move window behind current key window, , in front of other windows behind key window.
hth