Skip to content

Commit

Permalink
Feature: Added support for cycling tabs via mouse scrolling (files-co…
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrahambo authored Nov 30, 2023
1 parent 2e6238d commit 6bbe47c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Files.App/UserControls/TabBar/TabBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
CanReorderTabs="{x:Bind AllowTabsDrag, Mode=OneWay}"
DragLeave="TabView_DragLeave"
IsAddTabButtonVisible="False"
PointerWheelChanged="TabView_PointerWheelChanged"
SelectedIndex="{x:Bind root:App.AppModel.TabStripSelectedIndex, Mode=TwoWay}"
SelectionChanged="TabView_SelectionChanged"
TabCloseRequested="TabView_TabCloseRequested"
Expand Down
20 changes: 20 additions & 0 deletions src/Files.App/UserControls/TabBar/TabBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,26 @@ private async void TabView_TabDroppedOutside(TabView sender, TabViewTabDroppedOu
(args.Item as TabBarItem)?.Unload();
}

private void TabView_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
var delta = e.GetCurrentPoint(null).Properties.MouseWheelDelta;

if (delta > 0)
{
// Scroll up, select the next tab
if (HorizontalTabView.SelectedIndex < HorizontalTabView.TabItems.Count - 1)
HorizontalTabView.SelectedIndex++;
}
else
{
// Scroll down, select the previous tab
if (HorizontalTabView.SelectedIndex > 0)
HorizontalTabView.SelectedIndex--;
}

e.Handled = true;
}

private void TabItemContextMenu_Opening(object sender, object e)
{
MenuItemMoveTabToNewWindow.IsEnabled = Items.Count > 1;
Expand Down

0 comments on commit 6bbe47c

Please sign in to comment.