code_review: PR #190

* check middle button click before other action
* pass clicked tab instead of null to avoid closing current active page while clicking on other invalid tab
This commit is contained in:
leo 2024-06-20 09:25:56 +08:00
parent f3e54369ad
commit 7241879f5a
No known key found for this signature in database

View file

@ -258,17 +258,19 @@ namespace SourceGit.Views
private void OnPointerPressedTab(object sender, PointerPressedEventArgs e) private void OnPointerPressedTab(object sender, PointerPressedEventArgs e)
{ {
_pressedTab = true; var border = sender as Border;
_startDragTab = false; var point = e.GetCurrentPoint(border);
_pressedTabPosition = e.GetPosition(sender as Border); if (point.Properties.IsMiddleButtonPressed)
_pressedPoint = e.GetCurrentPoint(sender as Border);
if (_pressedPoint.Properties.IsMiddleButtonPressed)
{ {
var vm = DataContext as ViewModels.Launcher; var vm = DataContext as ViewModels.Launcher;
vm.CloseTab(null); vm.CloseTab(border.DataContext as ViewModels.LauncherPage);
e.Handled = true; e.Handled = true;
return; return;
} }
_pressedTab = true;
_startDragTab = false;
_pressedTabPosition = e.GetPosition(sender as Border);
} }
private void OnPointerReleasedTab(object sender, PointerReleasedEventArgs e) private void OnPointerReleasedTab(object sender, PointerReleasedEventArgs e)
@ -339,6 +341,5 @@ namespace SourceGit.Views
private bool _pressedTab = false; private bool _pressedTab = false;
private Point _pressedTabPosition = new Point(); private Point _pressedTabPosition = new Point();
private bool _startDragTab = false; private bool _startDragTab = false;
private PointerPoint _pressedPoint = new PointerPoint();
} }
} }