using System.Windows; using static QuikDawEditor.EDITING.StaticProperties; namespace QuikDawEditor; public partial class InputBox : Window { public InputBox(string titleText, string defaultText = "") { InitializeComponent(); TitleTB.Text = titleText; InputTB.Text = defaultText; TitleTB.Focus(); } public string Result = "Cancel"; //default public string TextBoxText; private void CancelButton_Click(object sender, RoutedEventArgs e) { CancelPressed(); } private void OkButton_Click(object sender, RoutedEventArgs e) { OkPressed(); } private void OkPressed() { if (InputTB.Text == "") { MessageBox.Show("Empty input not allowed"); return; } Result = "Ok"; TextBoxText = InputTB.Text; this.Close(); } private void CancelPressed() { Result = "Cancel"; this.Close(); } private void InputTB_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) OkPressed(); if (e.Key == System.Windows.Input.Key.Escape) CancelPressed(); } private void Window_Loaded(object sender, RoutedEventArgs e) { InputTB.Focus(); HotKeysDisabled = true; } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { HotKeysDisabled = false; } }