void Update() { if (focusedPanel == null) { return; } if (focusedPanel != null && !isAppFocused && ShouldIgnoreEventsOnAppNotFocused()) { return; } if (sendIMGUIEvents) { while (Event.PopEvent(m_Event)) { if (m_Event.type == EventType.Repaint) { continue; } var panelPosition = Vector2.zero; var panelDelta = Vector2.zero; if (ScreenToPanel(focusedPanelRenderer, m_Event.mousePosition, m_Event.delta, out panelPosition, out panelDelta)) { m_Event.mousePosition = panelPosition; m_Event.delta = panelDelta; using (EventBase evt = InternalBridge.CreateEvent(m_Event)) { focusedPanel.visualTree.SendEvent(evt); } } } } if (sendInputEvents) { if (sendNavigationEvents) { bool sendNavigationMove = ShouldSendMoveFromInput(); if (sendNavigationMove) { using (EventBase evt = NavigationMoveEvent.GetPooled(GetRawMoveVector())) { focusedPanel.visualTree.SendEvent(evt); } } if (input.GetButtonDown(m_SubmitButton)) { using (EventBase evt = NavigationSubmitEvent.GetPooled()) { focusedPanel.visualTree.SendEvent(evt); } } if (input.GetButtonDown(m_CancelButton)) { using (EventBase evt = NavigationCancelEvent.GetPooled()) { focusedPanel.visualTree.SendEvent(evt); } } } if (!ProcessTouchEvents() && input.mousePresent) { ProcessMouseEvents(); } } }
private void ProcessMouseEvents() { Vector2 pos = new Vector2(input.mousePosition.x, Screen.height - input.mousePosition.y); bool isInsidePanel = ScreenToPanel(focusedPanelRenderer, ref m_Event, pos, m_LastMousePosition); //Setup for Mouse Down/Up m_Event.modifiers = EventModifiers.None; m_Event.pressure = 0; m_Event.clickCount = 0; m_Event.character = default(char); m_Event.keyCode = KeyCode.None; /* FIXME use camera display id */ m_Event.displayIndex = 0; m_Event.commandName = String.Empty; int buttonDownIndex = -1; for (var i = 2; i >= 0; --i) { if (input.GetMouseButtonDown(i)) { m_Event.type = EventType.MouseDown; buttonDownIndex = i; if (isInsidePanel) { m_Event.button = i; using (EventBase evt = InternalBridge.CreateEvent(m_Event)) { focusedPanel.visualTree.SendEvent(evt); } } } if (input.GetMouseButtonUp(i)) { m_Event.type = EventType.MouseUp; if (isInsidePanel) { m_Event.button = i; using (EventBase evt = InternalBridge.CreateEvent(m_Event)) { focusedPanel.visualTree.SendEvent(evt); } } } } if (pos != m_LastMousePosition) { m_LastMousePosition = pos; m_Event.type = EventType.MouseMove; if (isInsidePanel) { m_Event.button = buttonDownIndex; using (EventBase evt = InternalBridge.CreateEvent(m_Event)) { focusedPanel.visualTree.SendEvent(evt); } } } }
private void ProcessMouseEvents() { Vector2 pos = new Vector2(input.mousePosition.x, Screen.height - input.mousePosition.y); if (pos != m_LastMousePosition) { m_LastMousePosition = pos; m_Event.type = EventType.MouseMove; if (ScreenToPanel(focusedPanelRenderer, ref m_Event, pos, m_LastMousePosition)) { m_Event.button = input.GetMouseButtonDown(0) ? 0 : input.GetMouseButtonDown(1) ? 1 : input.GetMouseButtonDown(2) ? 2 : 0; m_Event.modifiers = EventModifiers.None; m_Event.pressure = 0; m_Event.clickCount = 0; m_Event.character = default(char); m_Event.keyCode = KeyCode.None; /* FIXME use camera display id */ m_Event.displayIndex = 0; m_Event.commandName = String.Empty; EventBase evt = InternalBridge.CreateEvent(m_Event); focusedPanel.visualTree.SendEvent(evt); } } for (var i = 0; i < 3; i++) { if (input.GetMouseButtonDown(i)) { m_Event.type = EventType.MouseDown; if (ScreenToPanel(focusedPanelRenderer, ref m_Event, pos, m_LastMousePosition)) { m_Event.button = i; m_Event.modifiers = EventModifiers.None; m_Event.pressure = 0; m_Event.clickCount = 0; m_Event.character = default(char); m_Event.keyCode = KeyCode.None; /* FIXME use camera display id */ m_Event.displayIndex = 0; m_Event.commandName = String.Empty; EventBase evt = InternalBridge.CreateEvent(m_Event); focusedPanel.visualTree.SendEvent(evt); } } if (input.GetMouseButtonUp(i)) { m_Event.type = EventType.MouseUp; if (ScreenToPanel(focusedPanelRenderer, ref m_Event, pos, m_LastMousePosition)) { m_Event.button = i; m_Event.modifiers = EventModifiers.None; m_Event.pressure = 0; m_Event.clickCount = 0; m_Event.character = default(char); m_Event.keyCode = KeyCode.None; /* FIXME use camera display id */ m_Event.displayIndex = 0; m_Event.commandName = String.Empty; EventBase evt = InternalBridge.CreateEvent(m_Event); focusedPanel.visualTree.SendEvent(evt); } } } }