Skip to content

Commit 411d55d

Browse files
committed
improve keyboard shortcut
1 parent 801ec22 commit 411d55d

File tree

6 files changed

+79
-4
lines changed

6 files changed

+79
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
- 2022-06-02 **1.0.7**
3+
- Support event ArrowKeyDown and ArrowKeyUp to move between items search and TreeView
4+
- Support press key Esc from keyboard to close Form.
25
- 2022-05-29 **1.0.6**
36
- Add tab lisp function and support reload update lisp function
47
- 2022-05-22 **1.0.5**

CadAddinManager/View/FrmAddInManager.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
MinHeight="400"
1414
d:DataContext="{d:DesignInstance viewModel:AddInManagerViewModel}"
1515
FocusManager.FocusedElement="{x:Reference tbxSearch}"
16+
PreviewKeyDown="CloseFormEvent"
1617
Icon="../Resources/dev.ico"
1718
mc:Ignorable="d">
1819
<Window.Resources>
@@ -47,7 +48,8 @@
4748
Grid.Row="0"
4849
Margin="5,0,5,0"
4950
VerticalAlignment="Center"
50-
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
51+
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
52+
PreviewKeyDown="HandleTextboxKeyPress">
5153
<TextBox.Resources>
5254
<VisualBrush
5355
x:Key="tbxText"
@@ -91,6 +93,7 @@
9193
FontSize="14"
9294
Foreground="SteelBlue"
9395
Header="Command"
96+
PreviewKeyDown="HandleTreeViewCommandKeyPress"
9497
IsSelected="{Binding IsTabCmdSelected}">
9598
<control:ExtendedTreeView
9699
x:Name="TreeViewCommand"
@@ -152,6 +155,7 @@
152155
FontSize="14"
153156
Foreground="SteelBlue"
154157
Header="Lisp Function"
158+
PreviewKeyDown="HandleTreeViewLispKeyPress"
155159
IsSelected="{Binding IsTabLispSelected}">
156160
<control:ExtendedTreeView
157161
x:Name="TreeViewLispFunction"

CadAddinManager/View/FrmAddInManager.xaml.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,69 @@ private void TbxDescription_OnLostKeyboardFocus(object sender, KeyboardFocusChan
3434
}
3535
viewModel.MAddinManagerBase.AddinManager.SaveToAimIni();
3636
}
37+
private void HandleTextboxKeyPress(object sender, KeyEventArgs e)
38+
{
39+
if(e.Key == Key.Down)
40+
{
41+
if (viewModel.IsTabCmdSelected)
42+
{
43+
TreeViewCommand.Focus();
44+
}
45+
if (viewModel.IsTabLispSelected)
46+
{
47+
TreeViewLispFunction.Focus();
48+
}
49+
else
50+
{
51+
LogControl.Focus();
52+
}
53+
}
54+
55+
}
56+
private void HandleTreeViewCommandKeyPress(object sender, KeyEventArgs e)
57+
{
58+
int indexCmd = TreeViewCommand.Items.IndexOf(TreeViewCommand.SelectedItem);
59+
if (e.Key == Key.Up && TabCommand.IsFocused)
60+
{
61+
tbxSearch.Focus();
62+
}
63+
else if (e.Key == Key.Up && indexCmd==0 && TabCommand.IsSelected)
64+
{
65+
TabCommand.Focus();
66+
}
67+
if (e.Key == Key.Down && TabCommand.IsSelected)
68+
{
69+
TreeViewCommand.Focus();
70+
}
71+
if (e.Key == Key.Enter)
72+
{
73+
viewModel.ExecuteAddinCommandClick();
74+
}
75+
76+
}
77+
private void HandleTreeViewLispKeyPress(object sender, KeyEventArgs e)
78+
{
79+
int indexCmd = TreeViewLispFunction.Items.IndexOf(TreeViewLispFunction.SelectedItem);
80+
if (e.Key == Key.Up && TabLispFunction.IsFocused)
81+
{
82+
tbxSearch.Focus();
83+
}
84+
else if (e.Key == Key.Up && indexCmd==0 && TabLispFunction.IsSelected)
85+
{
86+
TabLispFunction.Focus();
87+
}
88+
if (e.Key == Key.Down && TabLispFunction.IsSelected)
89+
{
90+
TreeViewLispFunction.Focus();
91+
}
92+
if (e.Key == Key.Enter)
93+
{
94+
viewModel.ExecuteAddinCommandClick();
95+
}
96+
97+
}
98+
private void CloseFormEvent(object sender, KeyEventArgs e)
99+
{
100+
if (e.Key == Key.Escape) Close();
101+
}
37102
}

CadAddinManager/ViewModel/AddInManagerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private ObservableCollection<AddinModel> FreshTreeItems(bool isSearchText, Addin
242242
return MainTrees;
243243
}
244244

245-
private void ExecuteAddinCommandClick()
245+
public void ExecuteAddinCommandClick()
246246
{
247247
try
248248
{

Installer/Installer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
const string projectName = "CadAddinManager";
1818
const string outputName = "CadAddinManager";
1919
const string outputDir = "output";
20-
const string version = "1.0.6";
20+
const string version = "1.0.7";
2121
var fileName = new StringBuilder().Append(outputName).Append("-").Append(version);
2222
var project = new Project
2323
{

Readme.MD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ Some feature include:
3737
- <kbd>F1</kbd> - Go link open source report some error,bug or feature request.
3838
- <kbd>Delete</kbd> - Quick remove by use right click or use from keyboard.
3939
- <kbd>Crt + MouseWheel</kbd> - Zoom in/out by use mouse wheel in command plugin.
40-
40+
- <kbd>Arrow Up</kbd> - Move from TreeView to search.
41+
- <kbd>Arrow Down</kbd> - Move from search to TreeView.
42+
- <kbd>Esc</kbd> - Quick Close Add-in Manager.
43+
- <kbd>Enter</kbd> - Quick Run Execute a command selected in Add-in Manager.
4144
## Add-In Manager
4245

4346
![](pic/AddinManager.gif)

0 commit comments

Comments
 (0)