Skip to content

Commit bf74ffc

Browse files
committed
fix: select right-clicked tree node before context menu
1 parent b6f5cac commit bf74ffc

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/SharpFM/MainWindow.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
<TextBlock Classes="Fluent2Subtitle" Text="Available Clips" />
178178
<TreeView
179179
x:Name="clipsTreeView"
180+
ContextRequested="ClipsTree_ContextRequested"
180181
DoubleTapped="ClipsTree_DoubleTapped"
181182
ItemsSource="{Binding RootNodes}"
182183
Tapped="ClipsTree_Tapped">

src/SharpFM/MainWindow.axaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,17 @@ private void ClipsTree_Tapped(object? sender, TappedEventArgs e)
229229
vm.OpenClipAsPreview(node.Clip);
230230
}
231231

232+
// Right-click bypasses the Tapped handler, so the context menu would
233+
// otherwise operate on whatever was previously selected. Promote the
234+
// right-clicked node into the active selection before the menu opens.
235+
private void ClipsTree_ContextRequested(object? sender, ContextRequestedEventArgs e)
236+
{
237+
if (DataContext is not MainWindowViewModel vm) return;
238+
var node = FindClipNode(e.Source);
239+
if (node?.Clip is null) return;
240+
vm.OpenClipAsPreview(node.Clip);
241+
}
242+
232243
private void ClipsTree_DoubleTapped(object? sender, TappedEventArgs e)
233244
{
234245
if (DataContext is not MainWindowViewModel vm) return;

0 commit comments

Comments
 (0)