From 0d6af369c49522a8ca95dd256384d1d4d7eb00b1 Mon Sep 17 00:00:00 2001 From: maj00r Date: Sun, 4 Oct 2026 18:11:59 +0200 Subject: [PATCH] Open no menu on a scenery group in the tree --- StarterNG/Views/Scenarios.axaml.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/StarterNG/Views/Scenarios.axaml.cs b/StarterNG/Views/Scenarios.axaml.cs index 9258a0e..7e8d6da 100644 --- a/StarterNG/Views/Scenarios.axaml.cs +++ b/StarterNG/Views/Scenarios.axaml.cs @@ -101,11 +101,20 @@ public partial class Scenarios : UserControl ? Sceneries[index] : null; - // A right click picks the scenery under it, so the menu speaks of that one. + // A right click picks the scenery under it, so the menu speaks of that one. A + // group has nothing to star, and the menu is not opened on it at all - it would + // otherwise act on whatever scenery was selected before. private void SceneryList_OnContextRequested(object? sender, ContextRequestedEventArgs e) { - if ((e.Source as Visual).FindAncestorOfType(includeSelf: true) is { Tag: int } item) - sceneryList.SelectedItem = item; + switch ((e.Source as Visual).FindAncestorOfType(includeSelf: true)) + { + case { Tag: int } item: + sceneryList.SelectedItem = item; + break; + case not null: + e.Handled = true; + break; + } } private void SceneryMenu_OnOpening(object? sender, CancelEventArgs e)