Skip to content

Commit 846333a

Browse files
committed
Initial commit
1 parent 09e10c4 commit 846333a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Globalization;
3+
using System.Windows.Controls;
34
using System.Windows.Data;
45
using Flow.Launcher.Infrastructure.Logger;
56
using Flow.Launcher.ViewModel;
@@ -10,19 +11,21 @@ public class QuerySuggestionBoxConverter : IMultiValueConverter
1011
{
1112
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
1213
{
13-
if (values.Length != 2)
14+
if (values.Length != 3)
1415
{
1516
return string.Empty;
1617
}
17-
18+
var QueryText = values[1] as TextBox;
19+
var Suggestion = values[0] as TextBox;
20+
Suggestion.ScrollToHorizontalOffset(QueryText.HorizontalOffset);
1821
// first prop is the current query string
19-
var queryText = (string)values[0];
22+
var queryText = QueryText.Text;
2023

2124
if (string.IsNullOrEmpty(queryText))
2225
return string.Empty;
2326

2427
// second prop is the current selected item result
25-
var val = values[1];
28+
var val = values[2];
2629
if (val == null)
2730
{
2831
return string.Empty;

Flow.Launcher/MainWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@
161161
Style="{DynamicResource QuerySuggestionBoxStyle}">
162162
<TextBox.Text>
163163
<MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}">
164-
<Binding ElementName="QueryTextBox" Path="Text" />
164+
<Binding RelativeSource="{RelativeSource self}" Mode="OneTime" />
165+
<Binding ElementName="QueryTextBox" Mode="OneTime" />
165166
<Binding ElementName="ResultListBox" Path="SelectedItem" />
166167
</MultiBinding>
167168
</TextBox.Text>
@@ -171,10 +172,9 @@
171172
AllowDrop="True"
172173
Background="Transparent"
173174
PreviewDragOver="OnPreviewDragOver"
174-
Style="{DynamicResource QueryBoxStyle}"
175-
SelectionChanged="TextBox_SelectionChanged"
175+
Style="{DynamicResource QueryBoxStyle }"
176176
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
177-
Visibility="Visible">
177+
Visibility="Visible" Margin="16,7,0,7">
178178
<TextBox.ContextMenu>
179179
<ContextMenu>
180180
<MenuItem Command="ApplicationCommands.Cut" />

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ private void InitProgressbarAnimation()
262262

263263
private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)
264264
{
265-
265+
266266
// QueryTextSuggestionBox.ScrollToCaret();
267-
QueryTextSuggestionBox.ScrollToLine(QueryTextBox.GetLineIndexFromCharacterIndex(QueryTextBox.SelectionStart));
268267
QueryTextSuggestionBox.CaretIndex = QueryTextBox.CaretIndex;
268+
QueryTextSuggestionBox.ScrollToHorizontalOffset(QueryTextBox.HorizontalOffset);
269+
270+
269271
}
270272

271273
public void WindowAnimator()

0 commit comments

Comments
 (0)