protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt == null) { return; } if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if (!parentTextField.isDelayed || (!multiline && ((kde?.keyCode == KeyCode.KeypadEnter) || (kde?.keyCode == KeyCode.Return)))) { parentTextField.value = text; } if (multiline) { if (kde?.character == '\t' && kde.modifiers == EventModifiers.None) { kde?.StopPropagation(); kde?.PreventDefault(); } else if (((kde?.character == 3) && (kde?.shiftKey == true)) || // KeyCode.KeypadEnter ((kde?.character == '\n') && (kde?.shiftKey == true))) // KeyCode.Return { parent.Focus(); evt.StopPropagation(); evt.PreventDefault(); } } else if ((kde?.character == 3) || // KeyCode.KeypadEnter (kde?.character == '\n')) // KeyCode.Return { parent.Focus(); evt.StopPropagation(); evt.PreventDefault(); } } else if (evt.eventTypeId == ExecuteCommandEvent.TypeId()) { ExecuteCommandEvent commandEvt = evt as ExecuteCommandEvent; string cmdName = commandEvt.commandName; if (!parentTextField.isDelayed && (cmdName == EventCommandNames.Paste || cmdName == EventCommandNames.Cut)) { parentTextField.value = text; } } // Prevent duplicated navigation events, since we're observing KeyDownEvents instead else if (evt.eventTypeId == NavigationSubmitEvent.TypeId() || evt.eventTypeId == NavigationCancelEvent.TypeId() || evt.eventTypeId == NavigationMoveEvent.TypeId()) { evt.StopPropagation(); evt.PreventDefault(); } }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt == null) { return; } if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent kde = evt as KeyDownEvent; if (!parentTextField.isDelayed || (!multiline && ((kde?.keyCode == KeyCode.KeypadEnter) || (kde?.keyCode == KeyCode.Return)))) { parentTextField.value = text; } if (multiline) { if (kde?.character == '\t') { kde?.StopPropagation(); kde?.PreventDefault(); } else if (((kde?.character == 3) && (kde?.shiftKey == true)) || // KeyCode.KeypadEnter ((kde?.character == '\n') && (kde?.shiftKey == true))) // KeyCode.Return { parent.Focus(); } } else if ((kde?.character == 3) || // KeyCode.KeypadEnter (kde?.character == '\n')) // KeyCode.Return { parent.Focus(); } } else if (evt.eventTypeId == ExecuteCommandEvent.TypeId()) { ExecuteCommandEvent commandEvt = evt as ExecuteCommandEvent; string cmdName = commandEvt.commandName; if (!parentTextField.isDelayed && (cmdName == EventCommandNames.Paste || cmdName == EventCommandNames.Cut)) { parentTextField.value = text; } } }
void OnKeyDown(KeyDownEvent evt) { SliderKey sliderKey = SliderKey.None; bool isHorizontal = direction == SliderDirection.Horizontal; if (isHorizontal && evt.keyCode == KeyCode.Home || !isHorizontal && evt.keyCode == KeyCode.End) { sliderKey = inverted ? SliderKey.Highest : SliderKey.Lowest; } else if (isHorizontal && evt.keyCode == KeyCode.End || !isHorizontal && evt.keyCode == KeyCode.Home) { sliderKey = inverted ? SliderKey.Lowest : SliderKey.Highest; } else if (isHorizontal && evt.keyCode == KeyCode.PageUp || !isHorizontal && evt.keyCode == KeyCode.PageDown) { sliderKey = inverted ? SliderKey.HigherPage : SliderKey.LowerPage; } else if (isHorizontal && evt.keyCode == KeyCode.PageDown || !isHorizontal && evt.keyCode == KeyCode.PageUp) { sliderKey = inverted ? SliderKey.LowerPage : SliderKey.HigherPage; } else if (isHorizontal && evt.keyCode == KeyCode.LeftArrow || !isHorizontal && evt.keyCode == KeyCode.DownArrow) { sliderKey = inverted ? SliderKey.Higher : SliderKey.Lower; } else if (isHorizontal && evt.keyCode == KeyCode.RightArrow || !isHorizontal && evt.keyCode == KeyCode.UpArrow) { sliderKey = inverted ? SliderKey.Lower : SliderKey.Higher; } if (sliderKey == SliderKey.None) { return; } ComputeValueFromKey(sliderKey, evt.shiftKey); evt.StopPropagation(); }
public void OnKeyDown(KeyDownEvent evt) { int selectedIndex = this.m_ListView.selectedIndex; bool flag = true; KeyCode keyCode = evt.keyCode; KeyCode keyCode2 = keyCode; if (keyCode2 != KeyCode.RightArrow) { if (keyCode2 != KeyCode.LeftArrow) { flag = false; } else { bool flag2 = this.IsExpandedByIndex(selectedIndex); if (flag2) { this.CollapseItemByIndex(selectedIndex); } } } else { bool flag3 = !this.IsExpandedByIndex(selectedIndex); if (flag3) { this.ExpandItemByIndex(selectedIndex); } } bool flag4 = flag; if (flag4) { evt.StopPropagation(); } }
void OnKeyDown(KeyDownEvent evt) { if (!textInputField.hasFocus) { return; } textInputField.SyncTextEngine(); m_Changed = false; // Check for action keys. if (editorEngine.HandleKeyEvent(evt.imguiEvent, textInputField.isReadOnly)) { if (textInputField.text != editorEngine.text) { m_Changed = true; } evt.StopPropagation(); } else { char c = evt.character; // Ignore tab & shift-tab in single-line text fields if (!editorEngine.multiline && (evt.keyCode == KeyCode.Tab || c == '\t')) { return; } // Ignore modifier+tab in multiline text fields if (editorEngine.multiline && (evt.keyCode == KeyCode.Tab || c == '\t') && evt.modifiers != EventModifiers.None) { return; } evt.StopPropagation(); if (c == '\n' && !editorEngine.multiline && !evt.altKey) { return; } // When the newline character is sent, we have to check if the shift key is down also... // In the multiline case, this is like a return on a single line if (c == '\n' && editorEngine.multiline && evt.shiftKey) { return; } if (!textInputField.AcceptCharacter(c)) { return; } // Simplest test: only allow the character if the display font supports it. Font font = editorEngine.style.font; if (font != null && font.HasCharacter(c) || c == '\n' || c == '\t') { // Input event editorEngine.Insert(c); m_Changed = true; } // On windows, key presses also send events with keycode but no character. Eat them up here. else if (c == 0) { // if we have a composition string, make sure we clear the previous selection. if (!string.IsNullOrEmpty(GUIUtility.compositionString)) { editorEngine.ReplaceSelection(""); m_Changed = true; } } } if (m_Changed) { editorEngine.text = textInputField.CullString(editorEngine.text); textInputField.UpdateText(editorEngine.text); } // Scroll offset might need to be updated editorEngine.UpdateScrollOffset(); }
void OnKeyDown(KeyDownEvent evt) { if (!textElement.edition.hasFocus) { return; } m_Changed = false; if (evt.keyCode == KeyCode.Escape) { textElement.edition.RestoreValueAndText(); textElement.parent.Focus(); } evt.GetEquivalentImguiEvent(m_ImguiEvent); if (editingUtilities.HandleKeyEvent(m_ImguiEvent, false)) { if (textElement.text != editingUtilities.text) { m_Changed = true; } evt.StopPropagation(); } else { char c = evt.character; // Ignore command and control keys, but not AltGr characters if (evt.actionKey && !(evt.altKey && c != '\0')) { return; } // Ignore tab & shift-tab in single-line text fields if (!textElement.edition.multiline && (evt.keyCode == KeyCode.Tab || c == '\t')) { return; } // Ignore modifier+tab in multiline text fields if ((evt.keyCode == KeyCode.Tab || c == '\t') && evt.modifiers != EventModifiers.None) { return; } evt.StopPropagation(); if ((c == '\n' || c == '\r' || c == k_LineFeed) && !textElement.edition.multiline && !evt.altKey) { return; } // When the newline character is sent, we have to check if the shift key is down also... // In the multiline case, this is like a return on a single line if (c == '\n' && textElement.edition.multiline && evt.shiftKey) { return; } if (!textElement.edition.AcceptCharacter(c)) { return; } if (c >= k_Space || c == '\t' || c == '\n' || c == '\r' || c == k_LineFeed) { editingUtilities.Insert(c); m_Changed = true; } // On windows, key presses also send events with keycode but no character. Eat them up here. else { // if we have a composition string, make sure we clear the previous selection. if (editingUtilities.UpdateImeState()) { m_Changed = true; } } } if (m_Changed) { UpdateLabel(); // UpdateScrollOffset needs the new geometry of the text to compute the new scrollOffset. textElement.uitkTextHandle.Update(); } // Scroll offset might need to be updated textElement.edition.UpdateScrollOffset?.Invoke(); }
public void OnKeyDown(KeyDownEvent evt) { if (evt == null || !HasValidDataAndBindings()) { return; } bool shouldStopPropagation = true; bool shouldScroll = true; switch (evt.keyCode) { case KeyCode.UpArrow: if (selectedIndex > 0) { selectedIndex = selectedIndex - 1; } break; case KeyCode.DownArrow: if (selectedIndex + 1 < itemsSource.Count) { selectedIndex = selectedIndex + 1; } break; case KeyCode.Home: selectedIndex = 0; break; case KeyCode.End: selectedIndex = itemsSource.Count - 1; break; case KeyCode.Return: if (onItemChosen != null) { onItemChosen.Invoke(m_ItemsSource[selectedIndex]); } break; case KeyCode.PageDown: selectedIndex = Math.Min(itemsSource.Count - 1, selectedIndex + (int)(m_LastHeight / itemHeight)); break; case KeyCode.PageUp: selectedIndex = Math.Max(0, selectedIndex - (int)(m_LastHeight / itemHeight)); break; case KeyCode.A: if (evt.actionKey) { SelectAll(); shouldScroll = false; } break; case KeyCode.Escape: ClearSelection(); shouldScroll = false; break; default: shouldStopPropagation = false; shouldScroll = false; break; } if (shouldStopPropagation) { evt.StopPropagation(); } if (shouldScroll) { ScrollToItem(selectedIndex); } }
private void OnKeyDown(KeyDownEvent evt) { bool flag = !base.textInputField.hasFocus; if (!flag) { base.textInputField.SyncTextEngine(); this.m_Changed = false; evt.GetEquivalentImguiEvent(this.m_ImguiEvent); bool flag2 = base.editorEngine.HandleKeyEvent(this.m_ImguiEvent, base.textInputField.isReadOnly); if (flag2) { bool flag3 = base.textInputField.text != base.editorEngine.text; if (flag3) { this.m_Changed = true; } evt.StopPropagation(); } else { char character = evt.character; bool flag4 = !base.editorEngine.multiline && (evt.keyCode == KeyCode.Tab || character == '\t'); if (flag4) { return; } bool flag5 = base.editorEngine.multiline && (evt.keyCode == KeyCode.Tab || character == '\t') && evt.modifiers > EventModifiers.None; if (flag5) { return; } bool flag6 = evt.actionKey && (!evt.altKey || character == '\0'); if (flag6) { return; } evt.StopPropagation(); bool flag7 = character == '\n' && !base.editorEngine.multiline && !evt.altKey; if (flag7) { return; } bool flag8 = character == '\n' && base.editorEngine.multiline && evt.shiftKey; if (flag8) { return; } bool flag9 = !base.textInputField.AcceptCharacter(character); if (flag9) { return; } Font font = base.editorEngine.style.font; bool flag10 = (font != null && font.HasCharacter(character)) || character == '\n' || character == '\t'; if (flag10) { base.editorEngine.Insert(character); this.m_Changed = true; } else { bool flag11 = character == '\0'; if (flag11) { bool flag12 = !string.IsNullOrEmpty(GUIUtility.compositionString); if (flag12) { base.editorEngine.ReplaceSelection(""); this.m_Changed = true; } } } } bool changed = this.m_Changed; if (changed) { base.editorEngine.text = base.textInputField.CullString(base.editorEngine.text); base.textInputField.UpdateText(base.editorEngine.text); } base.editorEngine.UpdateScrollOffset(); } }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); bool flag = evt == null; if (!flag) { bool flag2 = evt.eventTypeId == EventBase <KeyDownEvent> .TypeId(); if (flag2) { KeyDownEvent keyDownEvent = evt as KeyDownEvent; bool flag3 = !this.parentTextField.isDelayed || (!this.multiline && ((keyDownEvent != null && keyDownEvent.keyCode == KeyCode.KeypadEnter) || (keyDownEvent != null && keyDownEvent.keyCode == KeyCode.Return))); if (flag3) { this.parentTextField.value = base.text; } bool multiline = this.multiline; if (multiline) { char?c = (keyDownEvent != null) ? new char?(keyDownEvent.character) : null; int? num = c.HasValue ? new int?((int)c.GetValueOrDefault()) : null; int num2 = 9; bool flag4 = (num.GetValueOrDefault() == num2 & num.HasValue) && keyDownEvent.modifiers == EventModifiers.None; if (flag4) { if (keyDownEvent != null) { keyDownEvent.StopPropagation(); } if (keyDownEvent != null) { keyDownEvent.PreventDefault(); } } else { c = ((keyDownEvent != null) ? new char?(keyDownEvent.character) : null); num = (c.HasValue ? new int?((int)c.GetValueOrDefault()) : null); num2 = 3; bool arg_1EE_0; if (!(num.GetValueOrDefault() == num2 & num.HasValue) || keyDownEvent == null || !keyDownEvent.shiftKey) { c = ((keyDownEvent != null) ? new char?(keyDownEvent.character) : null); num = (c.HasValue ? new int?((int)c.GetValueOrDefault()) : null); num2 = 10; arg_1EE_0 = ((num.GetValueOrDefault() == num2 & num.HasValue) && keyDownEvent != null && keyDownEvent.shiftKey); } else { arg_1EE_0 = true; } bool flag5 = arg_1EE_0; if (flag5) { base.parent.Focus(); } } } else { char?c = (keyDownEvent != null) ? new char?(keyDownEvent.character) : null; int? num = c.HasValue ? new int?((int)c.GetValueOrDefault()) : null; int num2 = 3; bool arg_2B8_0; if (!(num.GetValueOrDefault() == num2 & num.HasValue)) { c = ((keyDownEvent != null) ? new char?(keyDownEvent.character) : null); num = (c.HasValue ? new int?((int)c.GetValueOrDefault()) : null); num2 = 10; arg_2B8_0 = (num.GetValueOrDefault() == num2 & num.HasValue); } else { arg_2B8_0 = true; } bool flag6 = arg_2B8_0; if (flag6) { base.parent.Focus(); } } } else { bool flag7 = evt.eventTypeId == EventBase <ExecuteCommandEvent> .TypeId(); if (flag7) { ExecuteCommandEvent executeCommandEvent = evt as ExecuteCommandEvent; string commandName = executeCommandEvent.commandName; bool flag8 = !this.parentTextField.isDelayed && (commandName == "Paste" || commandName == "Cut"); if (flag8) { this.parentTextField.value = base.text; } } else { NavigationDirection navigationDirection; bool flag9 = base.eventInterpreter.IsActivationEvent(evt) || base.eventInterpreter.IsCancellationEvent(evt) || (base.eventInterpreter.IsNavigationEvent(evt, out navigationDirection) && navigationDirection != NavigationDirection.Previous && navigationDirection != NavigationDirection.Next); if (flag9) { evt.StopPropagation(); evt.PreventDefault(); } } } } }