[GH-ISSUE #782] Behavior when selecting another item while right-clicking an item (SFTP) #638

Closed
opened 2026-02-26 11:59:08 +03:00 by kerem · 6 comments
Owner

Originally created by @itagagaki on GitHub (Nov 22, 2024).
Original GitHub issue: https://github.com/1Remote/1Remote/issues/782

Originally assigned to: @VShawn on GitHub.

In SFTP (and probably also in FTP), if you right-click on item A and the context menu appears, then left-click or right-click on item B, the selection does not move to item B. In this case, item B should become selected.

Originally created by @itagagaki on GitHub (Nov 22, 2024). Original GitHub issue: https://github.com/1Remote/1Remote/issues/782 Originally assigned to: @VShawn on GitHub. In SFTP (and probably also in FTP), if you right-click on item A and the context menu appears, then left-click or right-click on item B, the selection does not move to item B. In this case, item B should become selected.
kerem 2026-02-26 11:59:08 +03:00
Author
Owner

@VShawn commented on GitHub (Nov 23, 2024):

I'll check it later

<!-- gh-comment-id:2495456071 --> @VShawn commented on GitHub (Nov 23, 2024): I'll check it later
Author
Owner

@itagagaki commented on GitHub (Dec 6, 2024):

Make a note of what I found out during my investigation.

When I right-click somewhere other than the current selection, the events fire in the following order.

RightButtonDown
SelectionChanged
RightButtonUp
ContextMenuOpening

If I right-click on another item from this state, the RightButtonDown and SelectionChanged handlers are not visited. The handlers that are visited are in the following order.

ContextMenuClosing
RightButtonUp
ContextMenuOpening

So the selection is not changed.

<!-- gh-comment-id:2523501718 --> @itagagaki commented on GitHub (Dec 6, 2024): Make a note of what I found out during my investigation. When I right-click somewhere other than the current selection, the events fire in the following order. RightButtonDown SelectionChanged RightButtonUp ContextMenuOpening If I right-click on another item from this state, the `RightButtonDown` and `SelectionChanged` handlers are not visited. The handlers that are visited are in the following order. ContextMenuClosing RightButtonUp ContextMenuOpening So the selection is not changed.
Author
Owner

@itagagaki commented on GitHub (Dec 10, 2024):

I built a simple WPF application for experimentation.

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Height="450" Width="800">
    <Grid>
        <ListView>
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Menu Item 1" />
                    <MenuItem Header="Menu Item 2" />
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.Items>
                <ListViewItem>Item 1</ListViewItem>
                <ListViewItem>Item 2</ListViewItem>
                <ListViewItem>Item 3</ListViewItem>
                <ListViewItem>Item 4</ListViewItem>
                <ListViewItem>Item 5</ListViewItem>
            </ListView.Items>
        </ListView>
    </Grid>
</Window>

Then right-click on each item. Right-click only.
The results are as follows. The item is correctly selected by the framework.

https://github.com/user-attachments/assets/64e9f5c0-de54-4f35-ae7c-ac9d2e13e0e9

I port the above code to 1Remote.
(To display it in the same way as the "About" view, I had to add ShowInTaskbar="False" WindowStyle="None").

The result:

https://github.com/user-attachments/assets/4ef1ecc7-25f0-4f94-9ad9-ee5700de8995

It is correct that Item 1 is selected first, but the selection does not change after that.
The cause of the differences in results is still under investigation.

<!-- gh-comment-id:2532511985 --> @itagagaki commented on GitHub (Dec 10, 2024): I built a simple WPF application for experimentation. ``` <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Height="450" Width="800"> <Grid> <ListView> <ListView.ContextMenu> <ContextMenu> <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item 2" /> </ContextMenu> </ListView.ContextMenu> <ListView.Items> <ListViewItem>Item 1</ListViewItem> <ListViewItem>Item 2</ListViewItem> <ListViewItem>Item 3</ListViewItem> <ListViewItem>Item 4</ListViewItem> <ListViewItem>Item 5</ListViewItem> </ListView.Items> </ListView> </Grid> </Window> ``` Then right-click on each item. Right-click only. The results are as follows. The item is correctly selected by the framework. https://github.com/user-attachments/assets/64e9f5c0-de54-4f35-ae7c-ac9d2e13e0e9 I port the above code to 1Remote. ~~(To display it in the same way as the "About" view, I had to add `ShowInTaskbar="False" WindowStyle="None"`).~~ The result\: https://github.com/user-attachments/assets/4ef1ecc7-25f0-4f94-9ad9-ee5700de8995 It is correct that Item 1 is selected first, but the selection does not change after that. The cause of the differences in results is still under investigation.
Author
Owner

@itagagaki commented on GitHub (Dec 11, 2024):

Okay, I've got the tail.
Not sure if the modification below is correct, but it seems to work correctly if you do it anyway.

--- a/Shawn.Utils.WpfResources/Theme/Styles/Menu.xaml
+++ b/Shawn.Utils.WpfResources/Theme/Styles/Menu.xaml
@@ -452,7 +452,6 @@
         <Setter Property="OverridesDefaultStyle" Value="True" />
         <Setter Property="Grid.IsSharedSizeScope" Value="true" />
         <Setter Property="HasDropShadow" Value="True" />
-        <Setter Property="StaysOpen" Value="False" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type ContextMenu}">
<!-- gh-comment-id:2536433687 --> @itagagaki commented on GitHub (Dec 11, 2024): Okay, I've got the tail. Not sure if the modification below is correct, but it seems to work correctly if you do it anyway. ``` --- a/Shawn.Utils.WpfResources/Theme/Styles/Menu.xaml +++ b/Shawn.Utils.WpfResources/Theme/Styles/Menu.xaml @@ -452,7 +452,6 @@ <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="Grid.IsSharedSizeScope" Value="true" /> <Setter Property="HasDropShadow" Value="True" /> - <Setter Property="StaysOpen" Value="False" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ContextMenu}"> ```
Author
Owner

@VShawn commented on GitHub (Dec 12, 2024):

uh...Just need to remove one line?

I can't remember why I put StaysOpen=False there 😕 , but it seems removing it has no bad effect

<!-- gh-comment-id:2537541585 --> @VShawn commented on GitHub (Dec 12, 2024): uh...Just need to remove one line? I can't remember why I put `StaysOpen=False` there 😕 , but it seems removing it has no bad effect
Author
Owner

@itagagaki commented on GitHub (Dec 12, 2024):

Confirmed that the issue has been resolved 👍

<!-- gh-comment-id:2537661954 --> @itagagaki commented on GitHub (Dec 12, 2024): Confirmed that the issue has been resolved 👍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#638
No description provided.