protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { m_ColorField.HandleEvent(evt); } }
public override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt.GetEventTypeId() == MouseDownEvent.TypeId()) { OnMouseDown(evt as MouseDownEvent); } else if (evt.GetEventTypeId() == MouseUpEvent.TypeId()) { OnMouseUp(evt as MouseUpEvent); } else if (evt.GetEventTypeId() == MouseMoveEvent.TypeId()) { OnMouseMove(evt as MouseMoveEvent); } else if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { OnKeyDown(evt as KeyDownEvent); } else if (evt.GetEventTypeId() == ValidateCommandEvent.TypeId()) { OnValidateCommandEvent(evt as ValidateCommandEvent); } else if (evt.GetEventTypeId() == ExecuteCommandEvent.TypeId()) { OnExecuteCommandEvent(evt as ExecuteCommandEvent); } }
public override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt.GetEventTypeId() == MouseDownEvent.TypeId()) { OnMouseDown(evt as MouseDownEvent); } else if (evt.GetEventTypeId() == MouseUpEvent.TypeId()) { OnMouseUp(evt as MouseUpEvent); } else if (evt.GetEventTypeId() == MouseMoveEvent.TypeId()) { OnMouseMove(evt as MouseMoveEvent); } else if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { OnKeyDown(evt as KeyDownEvent); } else if (evt.GetEventTypeId() == IMGUIEvent.TypeId()) { OnIMGUIEvent(evt as IMGUIEvent); } }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (((evt as MouseDownEvent)?.button == (int)MouseButton.LeftMouse) || ((evt.GetEventTypeId() == KeyDownEvent.TypeId()) && ((evt as KeyDownEvent)?.character == '\n') || ((evt as KeyDownEvent)?.character == ' '))) { ShowMenu(); evt.StopPropagation(); } }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if (kde.character == '\n') { UpdateValueFromText(); } } }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); bool hasChanged = false; if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if ((kde?.character == 3) || // KeyCode.KeypadEnter (kde?.character == '\n')) // KeyCode.Return { // Here we should update the value, but it will be done when the blur event is handled... parent.Focus(); evt.StopPropagation(); evt.PreventDefault(); } else if (!isReadOnly) { hasChanged = true; } } else if (!isReadOnly && evt.eventTypeId == ExecuteCommandEvent.TypeId()) { ExecuteCommandEvent commandEvt = evt as ExecuteCommandEvent; string cmdName = commandEvt.commandName; if (cmdName == EventCommandNames.Paste || cmdName == EventCommandNames.Cut) { hasChanged = true; } } if (!hash128Field.isDelayed && hasChanged) { // Prevent text from changing when the value change // This allow expression (2+2) or string like 00123 to remain as typed in the TextField until enter is pressed m_UpdateTextFromValue = false; try { UpdateValueFromText(); } finally { m_UpdateTextFromValue = true; } } }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); bool hasChanged = false; if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if (kde.character == '\n') { UpdateValueFromText(); } else { hasChanged = true; } } else if (evt.GetEventTypeId() == ExecuteCommandEvent.TypeId()) { ExecuteCommandEvent commandEvt = evt as ExecuteCommandEvent; string cmdName = commandEvt.commandName; if (cmdName == EventCommandNames.Paste || cmdName == EventCommandNames.Cut) { hasChanged = true; } } if (!isDelayed && hasChanged) { // Prevent text from changing when the value change // This allow expression (2+2) or string like 00123 to remain as typed in the TextField until enter is pressed m_UpdateTextFromValue = false; try { UpdateValueFromText(); } finally { m_UpdateTextFromValue = true; } } }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt == null) { return; } if ((evt as MouseDownEvent)?.button == (int)MouseButton.LeftMouse) { OnMouseDown(evt as MouseDownEvent); } else if (evt.eventTypeId == KeyDownEvent.TypeId()) { var kdEvt = evt as KeyDownEvent; if (((evt as KeyDownEvent)?.keyCode == KeyCode.Space) || ((evt as KeyDownEvent)?.keyCode == KeyCode.KeypadEnter) || ((evt as KeyDownEvent)?.keyCode == KeyCode.Return)) { OnKeyboardEnter(); } else if (kdEvt.keyCode == KeyCode.Delete || kdEvt.keyCode == KeyCode.Backspace) { OnKeyboardDelete(); } } else if (evt.eventTypeId == DragUpdatedEvent.TypeId()) { OnDragUpdated(evt); } else if (evt.eventTypeId == DragPerformEvent.TypeId()) { OnDragPerform(evt); } else if (evt.eventTypeId == DragLeaveEvent.TypeId()) { OnDragLeave(); } }
public FocusChangeDirection GetFocusChangeDirection(Focusable currentFocusable, EventBase e) { if (e.eventTypeId == PointerDownEvent.TypeId()) { if (focusController.GetFocusableParentForPointerEvent(e.target as Focusable, out var target)) { return(VisualElementFocusChangeTarget.GetPooled(target)); } } if (e.eventTypeId == NavigationMoveEvent.TypeId()) { switch (((NavigationMoveEvent)e).direction) { case NavigationMoveEvent.Direction.Left: return(Left); case NavigationMoveEvent.Direction.Up: return(Up); case NavigationMoveEvent.Direction.Right: return(Right); case NavigationMoveEvent.Direction.Down: return(Down); } } //TODO: make NavigationTabEvent public and use it here else if (e.eventTypeId == KeyDownEvent.TypeId()) { var kde = (KeyDownEvent)e; // Important: using KeyDownEvent.character for focus prevents a TextField bug. // IMGUI sends KeyDownEvent with keyCode != None, then it sends another one with character != '\0'. // If we use keyCode instead of character, TextField will receive focus on the first KeyDownEvent, // then text will become selected and, in the case of multiline, the KeyDownEvent with character = '\t' // will immediately overwrite the text with a single Tab string. if (kde.character == (char)25 || kde.character == '\t') { return(kde.shiftKey ? Previous : Next); } } return(FocusChangeDirection.none); }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt.GetEventTypeId() == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if (!isDelayed || kde.character == '\n') { value = text; } } else if (evt.GetEventTypeId() == ExecuteCommandEvent.TypeId()) { ExecuteCommandEvent commandEvt = evt as ExecuteCommandEvent; string cmdName = commandEvt.commandName; if (!isDelayed && (cmdName == EventCommandNames.Paste || cmdName == EventCommandNames.Cut)) { value = text; } } }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt == null) { return; } if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent keyDownEvt = evt as KeyDownEvent; // We must handle the ETX (char 3) or the \n instead of the KeypadEnter or Return because the focus will // have the drawback of having the second event to be handled by the focused field. if ((keyDownEvt?.character == 3) || // KeyCode.KeypadEnter (keyDownEvt?.character == '\n')) // KeyCode.Return { visualInput?.Focus(); } } }
public FocusChangeDirection GetFocusChangeDirection(Focusable currentFocusable, EventBase e) { // FUTURE: // We could implement an extendable adapter system to convert event to a focus change direction. // This would enable new event sources to change the focus. if (currentFocusable as IMGUIContainer != null && e.imguiEvent != null) { // Let IMGUIContainer manage the focus change. return(FocusChangeDirection.none); } if (e.GetEventTypeId() == KeyDownEvent.TypeId()) { KeyDownEvent kde = e as KeyDownEvent; EventModifiers modifiers = kde.modifiers; if (kde.character == '\t') { if (currentFocusable == null) { // Dont start going around a focus ring if there is no current focused element. return(FocusChangeDirection.none); } else if ((modifiers & EventModifiers.Shift) == 0) { return(VisualElementFocusChangeDirection.right); } else { return(VisualElementFocusChangeDirection.left); } } } return(FocusChangeDirection.none); }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (elementPanel != null && elementPanel.contextualMenuManager != null) { elementPanel.contextualMenuManager.DisplayMenuIfEventMatches(evt, this); } if (evt?.eventTypeId == ContextualMenuPopulateEvent.TypeId()) { ContextualMenuPopulateEvent e = evt as ContextualMenuPopulateEvent; int count = e.menu.MenuItems().Count; BuildContextualMenu(e); if (count > 0 && e.menu.MenuItems().Count > count) { e.menu.InsertSeparator(null, count); } } else if (evt.eventTypeId == FocusInEvent.TypeId()) { SaveValueAndText(); } else if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent keyDownEvt = evt as KeyDownEvent; if (keyDownEvt?.keyCode == KeyCode.Escape) { RestoreValueAndText(); parent.Focus(); } } editorEventHandler.ExecuteDefaultActionAtTarget(evt); }
void SelectAllTypes(bool state, EventTypeSelection eventTypeSelection = EventTypeSelection.All) { foreach (KeyValuePair <long, bool> v in m_State.ToList()) { long eventTypeId = v.Key; if (eventTypeSelection == EventTypeSelection.All || (eventTypeSelection == EventTypeSelection.Mouse && (eventTypeId == MouseMoveEvent.TypeId() || eventTypeId == MouseOverEvent.TypeId() || eventTypeId == MouseDownEvent.TypeId() || eventTypeId == MouseUpEvent.TypeId() || eventTypeId == WheelEvent.TypeId() || eventTypeId == ContextClickEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Keyboard && (eventTypeId == KeyDownEvent.TypeId() || eventTypeId == KeyUpEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Drag && (eventTypeId == DragUpdatedEvent.TypeId() || eventTypeId == DragPerformEvent.TypeId() || eventTypeId == DragExitedEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Command && (eventTypeId == ValidateCommandEvent.TypeId() || eventTypeId == ExecuteCommandEvent.TypeId()))) { m_State[eventTypeId] = state; } else { // Unaffected should be reset to false m_State[eventTypeId] = false; } } UpdateValue(); }
void UpdateEventbaseInfo(EventDebuggerEventRecord eventBase, IEventHandler focused, IEventHandler capture) { ClearEventbaseInfo(); if (eventBase == null) { return; } m_EventbaseInfo.text += "Focused element: " + EventDebugger.GetObjectDisplayName(focused) + "\n"; m_EventbaseInfo.text += "Capture element: " + EventDebugger.GetObjectDisplayName(capture) + "\n"; if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Mouse position: " + eventBase.mousePosition + "\n"; m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId()) { m_EventbaseInfo.text += "Button: " + (eventBase.button == 0 ? "Left" : eventBase.button == 1 ? "Middle" : "Right") + "\n"; m_EventbaseInfo.text += "Click count: " + eventBase.clickCount + "\n"; } if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == WheelEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Pressed buttons: " + eventBase.pressedButtons + "\n"; } if (eventBase.eventTypeId == WheelEvent.TypeId()) { m_EventbaseInfo.text += "Mouse delta: " + eventBase.delta + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { if (char.IsControl(eventBase.character)) { m_EventbaseInfo.text += "Character: \\" + (byte)(eventBase.character) + "\n"; } else { m_EventbaseInfo.text += "Character: " + eventBase.character + "\n"; } m_EventbaseInfo.text += "Key code: " + eventBase.keyCode + "\n"; } if (eventBase.eventTypeId == ValidateCommandEvent.TypeId() || eventBase.eventTypeId == ExecuteCommandEvent.TypeId()) { m_EventbaseInfo.text += "Command: " + eventBase.commandName + "\n"; } }