Browse Source
Merge pull request #7891 from workgroupengineering/features/DevTools/Issue_7869_Automatically-Selected
feat(DevTools): Open DevTools with Focused Element Automatically Selected in Tree
pull/7893/head
Max Katz
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
13 additions and
3 deletions
-
src/Avalonia.Diagnostics/Diagnostics/DevTools.cs
-
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
|
|
|
@ -105,13 +105,15 @@ namespace Avalonia.Diagnostics |
|
|
|
|
|
|
|
private static IDisposable Open(Application? application, DevToolsOptions options, Window? owner = default) |
|
|
|
{ |
|
|
|
var focussedControl = KeyboardDevice.Instance?.FocusedElement as IControl; |
|
|
|
if (application is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
} |
|
|
|
if (s_open.TryGetValue(application, out var window)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
window.Activate(); |
|
|
|
window.SelectedControl(focussedControl); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
@ -122,7 +124,7 @@ namespace Avalonia.Diagnostics |
|
|
|
Height = options.Size.Height, |
|
|
|
}; |
|
|
|
window.SetOptions(options); |
|
|
|
|
|
|
|
window.SelectedControl(focussedControl); |
|
|
|
window.Closed += DevToolsClosed; |
|
|
|
s_open.Add(application, window); |
|
|
|
if (options.ShowAsChildWindow && owner is { }) |
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
{ |
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
var point = (topLevel as IInputRoot)?.MouseDevice?.GetPosition(topLevel) ?? default; |
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
|
|
|
|
return (IControl?)topLevel.GetVisualsAt(point, x => |
|
|
|
{ |
|
|
|
@ -255,5 +255,13 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal void SelectedControl(IControl? control) |
|
|
|
{ |
|
|
|
if (control is { }) |
|
|
|
{ |
|
|
|
(DataContext as MainViewModel)?.SelectControl(control); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|