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(); } }
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(); }
void OnKeyDown(KeyDownEvent evt) { if (!textInputField.hasFocus) { return; } textInputField.SyncTextEngine(); m_Changed = false; evt.GetEquivalentImguiEvent(m_ImguiEvent); // Check for action keys. if (editorEngine.HandleKeyEvent(m_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; } // Ignore command and control keys, but not AltGr characters if (evt.actionKey && !(evt.altKey && c != '\0')) { 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(); }