Hello,
I have a window that is used to edit & run scripts in a locally-created language. I am using a combination of DocumentWindows (each containing an Actipro SyntaxEditor), and ToolWindows to provide support features, e.g. listing all declared functions. All of the ToolWindows that I am currently using include a Themed DataGrid.
I'm trying to get my "functions list" ToolWindow to show the function body in the appropriate code editor (DocumentWindow) when the user double-clicks on a corresponding row in the datagrid. Everything is working fine, except that the code editor does not have focus after the double-click is handled.
I have tried everything (this.Activate(true), docksite.ActivatePrimaryWindow(), etc.) to get focus to the editor (DocumentWindow), with no success. By watching System.Windows.Input.Keyboard.FocusedElement and stepping through my event handler, I finally discovered that the editor IS getting focus, but as soon as execution leaves the double-click event handler, Keyboard.FocusedElement is again set back to my ToolWindow!
Here is some sample code to illustrate the issue:I'm not sure if the problem is that I'm trying to change focus from within an event handler, or there's something I need to do to allow the ToolWindow to release focus, or something else I haven't considered. Any help would be appreciated.
I have a window that is used to edit & run scripts in a locally-created language. I am using a combination of DocumentWindows (each containing an Actipro SyntaxEditor), and ToolWindows to provide support features, e.g. listing all declared functions. All of the ToolWindows that I am currently using include a Themed DataGrid.
I'm trying to get my "functions list" ToolWindow to show the function body in the appropriate code editor (DocumentWindow) when the user double-clicks on a corresponding row in the datagrid. Everything is working fine, except that the code editor does not have focus after the double-click is handled.
I have tried everything (this.Activate(true), docksite.ActivatePrimaryWindow(), etc.) to get focus to the editor (DocumentWindow), with no success. By watching System.Windows.Input.Keyboard.FocusedElement and stepping through my event handler, I finally discovered that the editor IS getting focus, but as soon as execution leaves the double-click event handler, Keyboard.FocusedElement is again set back to my ToolWindow!
Here is some sample code to illustrate the issue:
//
// Mouse Event handler in FunctionsView : ToolWindow
//
private void datagrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
ObservableFunctionRow item = datagrid.SelectedItem as ObservableFunctionRow;
// If item is not an ObservableFunctionRow, do nothing
if (item == null) return;
// Raise the function selected event, if there are any listeners
if (FunctionSelected != null) FunctionSelected(this, new FunctionSelectedEventArgs(item.Function));
}
//
// Custom Event handler in ScriptWindow : Window
//
private void FunctionsView_FunctionSelected(object sender, FunctionSelectedEventArgs e)
{
// A function was selected: jump to the location at which it is declared
// NOTE: this opens a new editor DocumentWindow if necessary, and always
// calls Activate() on it
ShowCodeFile(e.SelectedFunction.Location);
}