From 33d3af13c7baadfd89a57a86c2b8b12425478736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kon=C3=AD=C4=8Dek?= Date: Sun, 1 Aug 2010 15:21:18 +0000 Subject: [PATCH] Ctrl+T in the editor opens and focuses Context actions popup. Added tooltip so that the shortcut is discoverable. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6353 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/ContextActionsRenderer.cs | 15 +++++++++++++++ .../ContextActions/ContextActionsBulbControl.xaml | 5 ++++- .../ContextActions/ContextActionsService.cs | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs index f9f2f68ce5..fcd5af6e66 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs @@ -7,7 +7,9 @@ using System; using System.Collections.ObjectModel; using System.Linq; +using System.Windows.Input; using System.Windows.Threading; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.AvalonEdit; @@ -54,6 +56,8 @@ namespace ICSharpCode.AvalonEdit.AddIn this.editorView.TextArea.Caret.PositionChanged += CaretPositionChanged; + this.editorView.KeyDown += new KeyEventHandler(ContextActionsRenderer_KeyDown); + editor.TextArea.TextView.ScrollOffsetChanged += ScrollChanged; this.delayMoveTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMoveMilliseconds) }; this.delayMoveTimer.Stop(); @@ -62,6 +66,17 @@ namespace ICSharpCode.AvalonEdit.AddIn WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchSingleton_Workbench_ActiveViewContentChanged; } + void ContextActionsRenderer_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.T && Keyboard.Modifiers == ModifierKeys.Control) + { + if (popup != null && popup.Actions != null && popup.Actions.Actions != null && popup.Actions.Actions.Count > 0) { + popup.IsDropdownOpen = true; + popup.Focus(); + } + } + } + void WorkbenchSingleton_Workbench_ViewClosed(object sender, ViewContentEventArgs e) { try { diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml index 8ecba49a41..f03f2bb1a9 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml @@ -21,7 +21,10 @@ + BorderBrush="#485763" HorizontalAlignment="Left" MouseUp="Header_MouseUp" ToolTipService.ShowDuration="3000"> + + Available actions (Ctrl+T) + diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs index ea10e0d9dd..cf911d370d 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs @@ -39,6 +39,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// public IEnumerable GetAvailableActions(ITextEditor editor) { + if (ParserService.LoadSolutionProjectsThreadRunning) + yield break; var parseTask = ParserService.BeginParseCurrentViewContent(); parseTask.Wait(); var editorContext = new EditorContext(editor);