Skip to content

Commit fde52c9

Browse files
Fix: Clear search text on load to handle Revit shortcut bleed-through
Reverted the focus change to keep tbxSearch focused by default as requested. Added a Loaded event handler to clear SearchText using DispatcherPriority.ContextIdle, which ensures any characters from multi-key Revit shortcuts (like 'AA') are cleared while maintaining the default search focus. Fixes #76 Co-authored-by: chuongmep <31106432+chuongmep@users.noreply.github.com>
1 parent 570b741 commit fde52c9

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

AddInManager/View/FrmAddInManager.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
d:DesignHeight="600"
1818
d:DesignWidth="400"
1919
Closed="OnCloseApp"
20-
FocusManager.FocusedElement="{Binding ElementName=TabControl}"
20+
FocusManager.FocusedElement="{Binding ElementName=tbxSearch}"
2121
Icon="../Resources/dev.ico"
2222
Left="{model:SettingBinding AppLeft}"
2323
PreviewKeyDown="CloseFormEvent"
2424
SizeChanged="FrmSizeChanged"
2525
Top="{model:SettingBinding AppTop}"
26+
Loaded="FrmAddInManager_OnLoaded"
2627
mc:Ignorable="d">
2728
<Window.Resources>
2829
<ResourceDictionary>

AddInManager/View/FrmAddInManager.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public FrmAddInManager(AddInManagerViewModel vm)
2424
Title += DefaultSetting.Version;
2525
}
2626

27+
private void FrmAddInManager_OnLoaded(object sender, RoutedEventArgs e)
28+
{
29+
// GitHub Issue: https://github.com/chuongmep/RevitAddInManager/issues/76
30+
// When user use keyboard shortcut like "AA" to open AddInManager, the second "A" will be entered into tbxSearch
31+
// We clear the search text after the window is fully loaded and idle.
32+
Dispatcher.BeginInvoke(new Action(() =>
33+
{
34+
viewModel.SearchText = string.Empty;
35+
}), DispatcherPriority.ContextIdle);
36+
}
37+
2738
private void TbxDescription_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
2839
{
2940
if (viewModel.MAddinManagerBase.ActiveCmdItem != null && TabControl.SelectedIndex == 0)

0 commit comments

Comments
 (0)