Skip to content

Commit

Permalink
Allow pressing shift+enter for multiline text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoozeds committed Dec 28, 2024
1 parent e0e5f54 commit d02228a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/UnrealLocresEditor/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ private void MainWindow_KeyDown(object sender, KeyEventArgs e)
}
}

// Allow pressing shift+enter for multiline text.
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter && e.KeyModifiers == KeyModifiers.Shift)
{
if (sender is DataGrid grid && e.Source is TextBox textBox)
{
int caretIndex = textBox.CaretIndex;
string currentText = textBox.Text ?? string.Empty;
textBox.Text = currentText.Insert(caretIndex, Environment.NewLine);
textBox.CaretIndex = caretIndex + Environment.NewLine.Length;
e.Handled = true;
}
}
}

private void ShowFindDialog()
{
if (findDialog == null)
Expand Down Expand Up @@ -817,6 +833,7 @@ private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
_dataGrid = this.FindControl<DataGrid>("uiDataGrid");
_dataGrid.AddHandler(KeyDownEvent, DataGrid_PreviewKeyDown, RoutingStrategies.Tunnel);

_searchTextBox = this.FindControl<TextBox>("uiSearchTextBox");

Expand Down

0 comments on commit d02228a

Please sign in to comment.