mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-25 14:15:00 +00:00
refactor: use PointerPressed
event instead of ListBox.SelectionChanged
event to navigate to commit (#1230)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
345ad06aba
commit
7890f7abbf
4 changed files with 133 additions and 101 deletions
|
@ -318,6 +318,31 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnNodePointerPressed(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
var p = e.GetCurrentPoint(this);
|
||||
if (!p.Properties.IsLeftButtonPressed)
|
||||
return;
|
||||
|
||||
if (DataContext is not ViewModels.Repository repo)
|
||||
return;
|
||||
|
||||
if (sender is not Border { DataContext: ViewModels.BranchTreeNode node })
|
||||
return;
|
||||
|
||||
if (node.Backend is not Models.Branch branch)
|
||||
return;
|
||||
|
||||
if (BranchesPresenter.SelectedItems is { Count: > 0 })
|
||||
{
|
||||
var ctrl = OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control;
|
||||
if (e.KeyModifiers.HasFlag(ctrl) || e.KeyModifiers.HasFlag(KeyModifiers.Shift))
|
||||
return;
|
||||
}
|
||||
|
||||
repo.NavigateToCommit(branch.Head);
|
||||
}
|
||||
|
||||
private void OnNodesSelectionChanged(object _, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_disableSelectionChangingEvent)
|
||||
|
@ -343,9 +368,6 @@ namespace SourceGit.Views
|
|||
if (selected == null || selected.Count == 0)
|
||||
return;
|
||||
|
||||
if (selected.Count == 1 && selected[0] is ViewModels.BranchTreeNode { Backend: Models.Branch branch })
|
||||
repo.NavigateToCommit(branch.Head);
|
||||
|
||||
var prev = null as ViewModels.BranchTreeNode;
|
||||
foreach (var row in Rows)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue