Skip to content

Commit 178776f

Browse files
committed
fix popup empty when same key press, add reset pop msg when lost focus
1 parent 69b0dc9 commit 178776f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Flow.Launcher/HotkeyControl.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
VerticalContentAlignment="Center"
5151
input:InputMethod.IsInputMethodEnabled="False"
5252
PreviewKeyDown="TbHotkey_OnPreviewKeyDown"
53-
TabIndex="100" />
53+
TabIndex="100"
54+
LostFocus="tbHotkey_LostFocus"/>
5455
</Grid>
5556
</UserControl>

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ namespace Flow.Launcher
1414
{
1515
public partial class HotkeyControl : UserControl
1616
{
17+
private Brush tbMsgForegroundColorOriginal;
18+
19+
private string tbMsgTextOriginal;
20+
1721
public HotkeyModel CurrentHotkey { get; private set; }
1822
public bool CurrentHotkeyAvailable { get; private set; }
1923

@@ -24,6 +28,8 @@ public partial class HotkeyControl : UserControl
2428
public HotkeyControl()
2529
{
2630
InitializeComponent();
31+
tbMsgTextOriginal = tbMsg.Text;
32+
tbMsgForegroundColorOriginal = tbMsg.Foreground;
2733
}
2834

2935
private CancellationTokenSource hotkeyUpdateSource;
@@ -35,7 +41,6 @@ private void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
3541
hotkeyUpdateSource = new();
3642
var token = hotkeyUpdateSource.Token;
3743
e.Handled = true;
38-
tbMsg.Visibility = Visibility.Hidden;
3944

4045
//when alt is pressed, the real key should be e.SystemKey
4146
Key key = e.Key == Key.System ? e.SystemKey : e.Key;
@@ -104,5 +109,11 @@ public void SetHotkey(string keyStr, bool triggerValidate = true)
104109
private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey);
105110

106111
public new bool IsFocused => tbHotkey.IsFocused;
112+
113+
private void tbHotkey_LostFocus(object sender, RoutedEventArgs e)
114+
{
115+
tbMsg.Text = tbMsgTextOriginal;
116+
tbMsg.Foreground = tbMsgForegroundColorOriginal;
117+
}
107118
}
108119
}

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Flow.Launcher.Infrastructure.UserSettings;
44
using System;
55
using System.Windows;
6+
using System.Windows.Media;
67
using System.Windows.Navigation;
78

89
namespace Flow.Launcher.Resources.Pages
@@ -11,13 +12,20 @@ public partial class WelcomePage2
1112
{
1213
private Settings Settings { get; set; }
1314

15+
private Brush tbMsgForegroundColorOriginal;
16+
17+
private string tbMsgTextOriginal;
18+
1419
protected override void OnNavigatedTo(NavigationEventArgs e)
1520
{
1621
if (e.ExtraData is Settings settings)
1722
Settings = settings;
1823
else
1924
throw new ArgumentException("Unexpected Parameter setting.");
25+
2026
InitializeComponent();
27+
tbMsgTextOriginal = HotkeyControl.tbMsg.Text;
28+
tbMsgForegroundColorOriginal = HotkeyControl.tbMsg.Foreground;
2129

2230
HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey), false);
2331
}
@@ -36,6 +44,9 @@ private void HotkeyControl_OnLostFocus(object sender, RoutedEventArgs args)
3644
{
3745
HotKeyMapper.SetHotkey(new HotkeyModel(Settings.Hotkey), HotKeyMapper.OnToggleHotkey);
3846
}
47+
48+
HotkeyControl.tbMsg.Text = tbMsgTextOriginal;
49+
HotkeyControl.tbMsg.Foreground = tbMsgForegroundColorOriginal;
3950
}
4051
}
4152
}

0 commit comments

Comments
 (0)