/// <summary> /// There is a new challenger for screen focus! /// Do the logic for giving focus to this new element. /// /// Note: There should only be a single "Click" per update step. /// So the "Neither" enumeration is added to the LeftOrRight type. /// "Neither" clicks should fire focus changes, but not click changes. /// There are still problems with this method. Be careful with inadvertant recursion! /// </summary> /// <param name="element">The new element to get focus</param> /// <param name="clickType">Left of right click</param> public void SetNewFocus(ScreenElement element, LeftOrRight clickType) { // If nothing new is getting focus, then remove focus if (element == null) { if (this.screenFocus != null) { this.screenFocus.UnClicked(null); this.screenFocus = null; } return; } // Trigger Clicked and UnClicked events if (this.screenFocus == null) { this.screenFocus = element; element.Clicked(Input.MouseWorldPosition, clickType); } else if (this.screenFocus.Equals(element)) { element.Clicked(Input.MouseWorldPosition, clickType); } else { screenFocus.UnClicked(element); this.screenFocus = element; element.Clicked(Input.MouseWorldPosition, clickType); } }