Skip to content

Commit f624ba1

Browse files
author
L0rdKlappstuhl
committed
prototype implementation for up and down key.
1 parent 02f2e3f commit f624ba1

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

windowswitcher.app/AppViewModel.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ public AppViewModel(IWindowSwitcher _switcher)
5454
{
5555
System.Diagnostics.Process.Start("https://github.com/balazs4/windowswitcher/");
5656
});
57+
58+
SelectPrev = new LambdaCommand(_ =>
59+
{
60+
if(!Windows.MoveCurrentToPrevious())
61+
{
62+
//hacky tracky workaround works :D
63+
Windows.MoveCurrentToNext();
64+
}
65+
RaisePropertyChangedEvent("Windows");
66+
});
67+
68+
SelectNext = new LambdaCommand(_ =>
69+
{
70+
if (!Windows.MoveCurrentToNext())
71+
{
72+
//hacky tracky workaround works :D
73+
Windows.MoveCurrentToPrevious();
74+
}
75+
RaisePropertyChangedEvent("Windows");
76+
}
77+
);
5778
}
5879

5980
public string Title { get; private set; }
@@ -104,6 +125,10 @@ public ICollectionView Windows
104125
}
105126

106127

128+
public ICommand SelectNext { get; private set; }
129+
130+
public ICommand SelectPrev { get; private set; }
131+
107132
public ICommand Activate { get; private set; }
108133
public ICommand OpenLink { get; private set; }
109134
}

windowswitcher.app/MainWindow.xaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
BorderThickness="0"
5353
Background="{x:Static SystemColors.WindowBrush}"
5454
Foreground="{x:Static SystemColors.ControlTextBrush}"
55-
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"/>
55+
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" >
56+
<TextBox.InputBindings>
57+
<KeyBinding Key="Up" Command="{Binding Path=SelectPrev}" />
58+
<KeyBinding Key="Down" Command="{Binding Path=SelectNext}" />
59+
</TextBox.InputBindings>
60+
</TextBox>
5661
</Grid>
5762
<ListView Grid.Row="2"
5863
Margin="2,16"
@@ -65,6 +70,10 @@
6570
ScrollViewer.VerticalScrollBarVisibility="Disabled"
6671
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
6772
Opacity="0.8">
73+
<ListView.InputBindings>
74+
<KeyBinding Key="Up" Command="{Binding Path=SelectPrev}" />
75+
<KeyBinding Key="Down" Command="{Binding Path=SelectNext}" />
76+
</ListView.InputBindings>
6877
<ListView.ItemTemplate>
6978
<DataTemplate>
7079
<TextBlock

0 commit comments

Comments
 (0)