/// <summary> /// Notify the ui manager that an event occured. /// </summary> /// <param name="evt">Event raised.</param> public void NotifyEvent(Event evt) { // check for focus change due to mouse pressure or so. if (evt.Type == Event.EventType.MouseEvent) { MouseEvent mouseEvt = (MouseEvent)evt; Widget receiver = PickWidget(mouseEvt.Position); if (mouseEvt.StateChange == MouseEvent.MouseStateChange.ButtonPressed) { // The case where the receiver is null is finely handled implicitly. if (mouseEvt.Button == Mouse.Button.Left) { Widget clickedWindow = PickTopWidget(mouseEvt.Position); // Give focus to the widget if it doesn't have the focus yet if (HasFocus(receiver) == false) { // No // try to give focus to this widget: if (SetFocus(receiver) == false) { // refused for X reason, try to give it to the top widget: if (HasFocus(clickedWindow) == false) SetFocus(clickedWindow); } } // place the clicked window on top anyway. PushWidgetOnTop(clickedWindow); } if (receiver != null) { //In all the cases, we generate a click event. ClickEvent clickEvent = new ClickEvent(mouseEvt.Button); receiver.OnEvent(evt); if (clickEvent.Accepted) receiver.OnClickEvent(clickEvent); } } else if (mouseEvt.StateChange == MouseEvent.MouseStateChange.Moved) myCursor.Position = mouseEvt.Position; } // dispatch the event. Widget widget = myFocusedWidget; if (widget != null) { widget.OnEvent(evt); widget.DispatchEvent(evt); } }
/// <summary> /// Event generated when the widget is clicked on. /// </summary> /// <param name="clickEvent"></param> public virtual void OnClickEvent(ClickEvent clickEvent) { }