public void Update() { ToggleWindowByKeys(); if (window_.isOpen) { if (inputField.isFocused) { keyEvent_.Check(); } else { keyEvent_.Clear(); } if (window_.hasCompletion && KeyUtil.Enter()) { window_.DoCompletion(); } else if (IsEnterPressing()) { window_.OnSubmit(inputField.text); } } }
public bool IsEnterPressing() { if (!inputField.multiLine) { return(KeyUtil.Enter()); } else { return((KeyUtil.Control() || KeyUtil.Shift()) && KeyUtil.Enter()); } }
// To change default behavior and to support multiple gui, // override InputFiled method here. public override void OnUpdateSelected(BaseEventData eventData) { if (!isFocused) { return; } // To support multiple gui, set the window that this input filed is belonging to // as the current active window. Window.selected = parentWindow; bool consumedEvent = false; var e = new Event(); while (Event.PopEvent(e)) { if (e.rawType == EventType.KeyDown) { consumedEvent = true; // Skip because these keys are used for histroy selection in single-line mode // and for move cursor manually in multi-line mode. switch (e.keyCode) { case KeyCode.UpArrow: case KeyCode.DownArrow: continue; } // Skip if completion view is open. if (parentWindow.hasCompletion) { if (e.keyCode == KeyCode.Tab || KeyUtil.Enter()) { break; } } var shouldContinue = KeyPressed(e); // Prevent finish. // Command submission and cancel are observed and handled in Core. switch (e.keyCode) { case KeyCode.Return: case KeyCode.KeypadEnter: case KeyCode.Escape: shouldContinue = EditState.Continue; break; } if (shouldContinue == EditState.Finish) { DeactivateInputField(); break; } } } if (consumedEvent) { UpdateLabel(); } eventData.Use(); }