public idWindow SetFocus(idWindow window, bool scripts = true)
{
if(this.Disposed == true)
{
throw new ObjectDisposedException(this.GetType().Name);
}
// only one child can have the focus
idWindow lastFocus = null;
if((window.Flags & WindowFlags.CanFocus) == WindowFlags.CanFocus)
{
lastFocus = this.UserInterface.Desktop.FocusedChild;
if(lastFocus != null)
{
lastFocus.HandleFocusLost();
}
// call on lose focus
if((scripts == true) && (lastFocus != null))
{
// calling this broke all sorts of guis
// lastFocus->RunScript(ON_MOUSEEXIT);
}
// call on gain focus
if((scripts == true) && (window != null))
{
// calling this broke all sorts of guis
// w->RunScript(ON_MOUSEENTER);
}
window.HandleFocusGained();
this.UserInterface.Desktop.FocusedChild = window;
}
return lastFocus;
}