Skip to content

Fixed: Right click doesn't always select the file/folder hovered over #10078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ private void RefreshContainer(SelectorItem container, bool inRecycleQueue)
container.PointerPressed -= FileListItem_PointerPressed;
container.PointerEntered -= FileListItem_PointerEntered;
container.PointerExited -= FileListItem_PointerExited;
container.RightTapped -= FileListItem_RightTapped;

if (inRecycleQueue)
{
Expand All @@ -908,6 +909,7 @@ private void RefreshContainer(SelectorItem container, bool inRecycleQueue)
else
{
container.PointerPressed += FileListItem_PointerPressed;
container.RightTapped += FileListItem_RightTapped;
if (UserSettingsService.PreferencesSettingsService.SelectFilesOnHover)
{
container.PointerEntered += FileListItem_PointerEntered;
Expand Down Expand Up @@ -1012,6 +1014,15 @@ protected internal void FileListItem_PointerExited(object sender, PointerRoutedE
hoveredItem = null;
}

protected void FileListItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var rightClickedItem = GetItemFromElement(sender);
if (rightClickedItem != null && !((SelectorItem)sender).IsSelected)
{
ItemManipulationModel.SetSelectedItem(rightClickedItem);
}
}

private readonly RecycleBinHelpers recycleBinHelpers = new();

protected void InitializeDrag(UIElement containter, ListedItem item)
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/LayoutModes/ColumnViewBase.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
CornerRadius="{StaticResource ControlCornerRadius}"
IsRightTapEnabled="True"
Loaded="Grid_Loaded"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemName, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
Expand Down
11 changes: 0 additions & 11 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,17 +550,6 @@ private void FileList_ItemTapped(object sender, TappedRoutedEventArgs e)
}
}

private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var parentContainer = DependencyObjectHelpers.FindParent<ListViewItem>(e.OriginalSource as DependencyObject);

if (parentContainer.IsSelected)
return;

// The following code is only reachable when a user RightTapped an unselected row
ItemManipulationModel.SetSelectedItem(FileList.ItemFromContainer(parentContainer) as ListedItem);
}

private void Grid_Loaded(object sender, RoutedEventArgs e)
{
var itemContainer = (sender as Grid)?.FindAscendant<ListViewItem>();
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@
AutomationProperties.Name="{x:Bind ItemName, Mode=OneWay}"
IsRightTapEnabled="True"
Loaded="Grid_Loaded"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemTooltipText, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ColumnsViewModel.IconColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
Expand Down
9 changes: 0 additions & 9 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,6 @@ private void FolderSettings_LayoutModeChangeRequested(object sender, LayoutModeE
{
}

private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var parentContainer = DependencyObjectHelpers.FindParent<ListViewItem>(e.OriginalSource as DependencyObject);
if (!parentContainer.IsSelected)
{
ItemManipulationModel.SetSelectedItem(FileList.ItemFromContainer(parentContainer) as ListedItem);
}
}

private async void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SelectedItems = FileList.SelectedItems.Cast<ListedItem>().Where(x => x != null).ToList();
Expand Down
2 changes: 0 additions & 2 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
Background="Transparent"
IsRightTapEnabled="True"
Loaded="Grid_Loaded"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemTooltipText, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -214,7 +213,6 @@
ColumnSpacing="4"
IsRightTapEnabled="True"
Loaded="Grid_Loaded"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemTooltipText, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
9 changes: 0 additions & 9 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,6 @@ private void SetItemMinWidth()
NotifyPropertyChanged(nameof(GridViewItemMinWidth));
}

private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var parentContainer = DependencyObjectHelpers.FindParent<GridViewItem>(e.OriginalSource as DependencyObject);
if (!parentContainer.IsSelected)
{
ItemManipulationModel.SetSelectedItem(FileList.ItemFromContainer(parentContainer) as ListedItem);
}
}

private async void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SelectedItems = FileList.SelectedItems.Cast<ListedItem>().Where(x => x != null).ToList();
Expand Down