public override void OnGUI(Rect rect) { rect = RectHelper.Inset(rect, _padding); var add = false; var addRect = RectHelper.TakeTrailingWidth(ref rect, 32.0f); RectHelper.TakeTrailingWidth(ref rect, RectHelper.HorizontalSpace); using (new InvalidScope(_valid)) { using (var changes = new EditorGUI.ChangeCheckScope()) { add = EnterField.DrawString("AddWatchVariable", rect, GUIContent.none, ref _variable); if (changes.changed) { _valid = true; } } } if (GUI.Button(addRect, _addButton.Content)) { add = true; } if (add) { _valid = Window.AddWatch(_variable); if (_valid) { _variable = string.Empty; editorWindow.Close(); } else { editorWindow.Repaint(); } } }
// //----------------------------------------------------------------------------------------------------------------------------------------- // private void EnterField_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift) { EnterField.AppendText("\r\n"); EnterField.SelectionStart = EnterField.Text.Length; } else { SendMessage(EnterField.Text); EnterField.Text = ""; } } else if (e.Key == Key.A && e.KeyboardDevice.Modifiers == ModifierKeys.Control) { EnterField.SelectAll(); } }
private void DrawPrompt() { var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true)); var execute = false; var executeRect = RectHelper.TakeTrailingWidth(ref rect, 32.0f); RectHelper.TakeTrailingWidth(ref rect, RectHelper.HorizontalSpace); using (new EditorGUI.DisabledScope(!Application.isPlaying)) { using (new InvalidScope(_promptValid)) { using (var changes = new EditorGUI.ChangeCheckScope()) { execute = EnterField.DrawString("PromptEntry", rect, GUIContent.none, ref _promptText); if (changes.changed) { _promptValid = true; } } } if (GUI.Button(executeRect, _executeButton.Content)) { execute = true; } if (execute) { _promptValid = ExecuteExpression(_promptText); if (_promptValid) { _promptText = string.Empty; } } } }