Skip to content

Commit

Permalink
improve auto-scroll for code tool
Browse files Browse the repository at this point in the history
don't auto-scroll in response to gaining keyboard focus from the ViewModel
  • Loading branch information
haven1433 committed Jun 30, 2023
1 parent 419f83a commit 18d7bac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/HexManiac.WPF/Controls/TextEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ private void HandleViewModelCaretMove(object sender, EventArgs e) {
TransparentLayer.CaretIndex = vm.CaretIndex;
}

private void HandleViewModelRequestKeyboardFocus(object sender, EventArgs e) => Keyboard.Focus(TransparentLayer);
private void HandleViewModelRequestKeyboardFocus(object sender, EventArgs e) {
RequestBringIntoView += SuppressBringIntoView;
Keyboard.Focus(TransparentLayer);
RequestBringIntoView -= SuppressBringIntoView;
}

private void SuppressBringIntoView(object sender, RequestBringIntoViewEventArgs e) => e.Handled = true;

public void ScrollToVerticalOffset(double offset) => TransparentLayer.ScrollToVerticalOffset(offset);

Expand Down

0 comments on commit 18d7bac

Please # to comment.