public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { IMGUIContainer imguiContainer = panel.focusController.GetLeafFocusedElement() as IMGUIContainer; if (imguiContainer != null) { if (!evt.Skip(imguiContainer) && imguiContainer.HandleIMGUIEvent(evt.imguiEvent)) { evt.StopPropagation(); evt.PreventDefault(); } if (!evt.isPropagationStopped && evt.propagateToIMGUI) { evt.skipElements.Add(imguiContainer); EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } else if (panel.focusController.GetLeafFocusedElement() != null) { evt.target = panel.focusController.GetLeafFocusedElement(); EventDispatchUtilities.PropagateEvent(evt); } else { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } evt.propagateToIMGUI = false; evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { if (panel.focusController.GetLeafFocusedElement() != null) { IMGUIContainer imguiContainer = panel.focusController.GetLeafFocusedElement() as IMGUIContainer; if (imguiContainer != null) { // THINK ABOUT THIS PF: shouldn't we allow for the trickleDown dispatch phase? if (!evt.Skip(imguiContainer) && imguiContainer.HandleIMGUIEvent(evt.imguiEvent)) { evt.StopPropagation(); evt.PreventDefault(); } } else { evt.target = panel.focusController.GetLeafFocusedElement(); EventDispatchUtilities.PropagateEvent(evt); } } else { evt.target = panel.visualTree; EventDispatchUtilities.PropagateEvent(evt); if (!evt.isPropagationStopped) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } } evt.propagateToIMGUI = false; evt.stopDispatch = true; }
protected internal override void PostDispatch(IPanel panel) { base.PostDispatch(panel); if (!isPropagationStopped && !doNotSendToRootIMGUIContainer) { // The top IMGUIContainer is not in the path between the evt.target and unity-panel-container // We propagate the event to the top IMGUIContainer // this is an issue for window splitters that can't be clicked on the inner side of the window foreach (var element in panel.visualTree.Children()) { IMGUIContainer container = element as IMGUIContainer; // We must check that it is not the target or the event could be handled twice if (container != null && element != target) { if (container.HandleIMGUIEvent(this.imguiEvent, true)) { StopPropagation(); PreventDefault(); } } break; } } }