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.SendEventToIMGUI(evt)) { 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 virtual void DispatchEvent(EventBase evt, IPanel panel) { IPointerEvent pointerEvent = evt as IPointerEvent; BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; if (basePanel != null && pointerEvent != null) { bool shouldRecomputeTopElementUnderPointer = ((IPointerEventInternal)pointerEvent).recomputeTopElementUnderPointer; VisualElement elementUnderPointer = shouldRecomputeTopElementUnderPointer ? basePanel.Pick(pointerEvent.position) : basePanel.GetTopElementUnderPointer(pointerEvent.pointerId); if (evt.target == null) { evt.target = elementUnderPointer; } if (shouldRecomputeTopElementUnderPointer) { basePanel.SetElementUnderPointer(elementUnderPointer, evt); } } if (evt.target != null) { evt.propagateToIMGUI = false; EventDispatchUtilities.PropagateEvent(evt); } evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; // FIXME: we should not change hover state when capture is true. // However, when doing drag and drop, drop target should be highlighted. // TODO when EditorWindow is docked MouseLeaveWindow is not always sent // this is a problem in itself but it could leave some elements as "hover" BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; if (basePanel != null && (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() || evt.eventTypeId == DragExitedEvent.TypeId())) { basePanel.SetElementUnderPointer(null, evt); } else { // update element under mouse and fire necessary events if (basePanel != null) { bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel.Pick(mouseEvent.mousePosition) : basePanel.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null) { evt.target = elementUnderMouse; } basePanel.SetElementUnderPointer(elementUnderMouse, evt); } if (evt.target != null) { evt.propagateToIMGUI = false; EventDispatchUtilities.PropagateEvent(evt); } } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } evt.stopDispatch = true; }
static void SendEventToTarget(EventBase evt) { if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); } }
static void SendEventToTarget(EventBase evt, IPanel panel) { if (evt.target is VisualElement ve && ve.panel == panel) { EventDispatchUtilities.PropagateEvent(evt); } }
public void DispatchEvent(EventBase evt, IPanel panel) { if (evt.target is VisualElement ve && ve.panel == panel) { evt.propagateToIMGUI = ve.isIMGUIContainer; EventDispatchUtilities.PropagateEvent(evt); }
static void SendEventToRegularTarget(EventBase evt, IPanel panel) { if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); } }
public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } evt.propagateToIMGUI = false; evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { evt.target = panel.focusController.GetLeafFocusedElement() ?? panel.visualTree; EventDispatchUtilities.PropagateEvent(evt); } evt.propagateToIMGUI = false; evt.stopDispatch = true; }
public virtual void DispatchEvent(EventBase evt, IPanel panel) { IPointerEvent pointerEvent = evt as IPointerEvent; if (pointerEvent == null) { return; } BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; bool shouldRecomputeTopElementUnderPointer = true; if (evt is IPointerEventInternal) { shouldRecomputeTopElementUnderPointer = ((IPointerEventInternal)pointerEvent).recomputeTopElementUnderPointer; } VisualElement elementUnderPointer = shouldRecomputeTopElementUnderPointer ? basePanel?.Pick(pointerEvent.position) : basePanel?.GetTopElementUnderPointer(pointerEvent.pointerId); if (evt.target == null && elementUnderPointer != null) { evt.propagateToIMGUI = false; evt.target = elementUnderPointer; } else if (evt.target == null && elementUnderPointer == null) { // Event occured outside the window. // Send event to visual tree root and // don't modify evt.propagateToIMGUI. evt.target = panel?.visualTree; } else if (evt.target != null) { evt.propagateToIMGUI = false; } if (basePanel != null && shouldRecomputeTopElementUnderPointer) { basePanel.SetElementUnderPointer(elementUnderPointer, evt); } if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); } evt.stopDispatch = true; }
static void SendEventToIMGUIContainer(EventBase evt, IPanel panel) { if (panel != null) { if (evt.target != null && evt.target is IMGUIContainer) { evt.propagateToIMGUI = true; evt.skipElements.Add(evt.target); } if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } }
public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { // Note that here we always overwrite evt.target, even if it's already set. This might be required by // some pre-existing editor content, but it's not standard among the dispatching strategies and should // probably be changed in the future. var leafFocusElement = panel.focusController.GetLeafFocusedElement(); if (leafFocusElement != null) { evt.target = leafFocusElement; if (leafFocusElement.isIMGUIContainer) { IMGUIContainer imguiContainer = (IMGUIContainer)leafFocusElement; if (!evt.Skip(imguiContainer) && imguiContainer.SendEventToIMGUI(evt)) { evt.StopPropagation(); evt.PreventDefault(); } } else { 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; }
public void DispatchEvent(EventBase evt, IPanel panel) { if (panel != null) { var leafFocusElement = panel.focusController.GetLeafFocusedElement(); if (leafFocusElement != null) { if (leafFocusElement.isIMGUIContainer) { IMGUIContainer imguiContainer = (IMGUIContainer)leafFocusElement; if (!evt.Skip(imguiContainer) && imguiContainer.SendEventToIMGUI(evt)) { evt.StopPropagation(); evt.PreventDefault(); } } else { evt.target = leafFocusElement; 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; }
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.SendEventToIMGUI(evt)) { 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; }
public void DispatchEvent(EventBase evt, IPanel panel) { if (evt.target != null) { evt.propagateToIMGUI = evt.target is IMGUIContainer; EventDispatchUtilities.PropagateEvent(evt); } else { if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } } evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; if (mouseEvent == null) { return; } BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; // update element under mouse and fire necessary events bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel?.Pick(mouseEvent.mousePosition) : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null && elementUnderMouse != null) { evt.propagateToIMGUI = false; evt.target = elementUnderMouse; } else if (evt.target == null && elementUnderMouse == null) { // Event occured outside the window. // Send event to visual tree root and // don't modify evt.propagateToIMGUI. evt.target = panel?.visualTree; } else if (evt.target != null) { evt.propagateToIMGUI = false; } if (basePanel != null) { // If mouse leaves the window, make sure element under mouse is null. // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0) { basePanel.SetElementUnderPointer(null, evt); } else if (shouldRecomputeTopElementUnderMouse) { basePanel.SetElementUnderPointer(elementUnderMouse, evt); } } if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); if (evt.target is IMGUIContainer) { evt.propagateToIMGUI = true; evt.skipElements.Add(evt.target); } } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } else if (panel.visualTree.childCount > 0 && panel.visualTree[0] is IMGUIContainer) { // Send the events to the GUIView container so that it can process them. // This avoid elements near the edge of the window preventing the dock area splitter to work. // See case : https://fogbugz.unity3d.com/f/cases/1197851/ var topLevelIMGUI = (IMGUIContainer)panel.visualTree[0]; if (!evt.Skip(topLevelIMGUI) && evt.imguiEvent != null) { topLevelIMGUI.SendEventToIMGUI(evt, false); if (evt.imguiEvent.rawType == EventType.Used) { evt.StopPropagation(); } } } } evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; if (mouseEvent == null) { return; } BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; // update element under mouse and fire necessary events bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel?.Pick(mouseEvent.mousePosition) : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null && elementUnderMouse != null) { evt.propagateToIMGUI = false; evt.target = elementUnderMouse; } else if (evt.target == null && elementUnderMouse == null) { // Don't modify evt.propagateToIMGUI. evt.target = panel?.visualTree; } else if (evt.target != null) { evt.propagateToIMGUI = false; } if (basePanel != null) { // If mouse leaves the window, make sure element under mouse is null. // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0) { basePanel.SetElementUnderPointer(null, evt); } else if (shouldRecomputeTopElementUnderMouse) { basePanel.SetElementUnderPointer(elementUnderMouse, evt); } } if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } evt.stopDispatch = true; }