-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HotKeys Page to DevTools #15700
Add HotKeys Page to DevTools #15700
Conversation
@@ -231,6 +236,11 @@ private set | |||
private set => RaiseAndSetIfChanged(ref _pointerOverElementName, value); | |||
} | |||
|
|||
public void ShowHotKeys() | |||
{ | |||
SelectedTab = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit cludgy here, but changing SelectedTab
is necessary so other tabs do not remain selected.
You can test this PR using the following package version. |
src/Avalonia.Diagnostics/Diagnostics/ViewModels/HotKeyPageViewModel.cs
Outdated
Show resolved
Hide resolved
You can test this PR using the following package version. |
0761e38 introduces I added It's much closer to mutability, but kept it internal so any implementer could revise. This PR doesn't support multiple gestures that can each launch the same action. Chrome DevTools has this. |
possible enhanced public enum HotKeyFunction
{
[Description("Launch DevTools")]
LaunchDevTools,
[Description("Inspect Control Under Pointer")]
InspectHoveredControl,
[Description("Freeze Value Frames")]
FramesFreeze,
[Description("Unfreeze Value Frames")]
FramesUnfreeze,
[Description("Toggle Popup Freeze")]
TogglePopupFreeze,
[Description("Screenshot Selected Control")]
ScreenshotSelectedControl
}
public class DevToolsOptions
{
private readonly static KeyGesture DefaultLaunchDevToolsGesture = new(Key.F12);
private readonly Dictionary<HotKeyFunction, KeyGesture> _hotkeyConfig = new()
{
{HotKeyFunction.LaunchDevTools,new(Key.F12) },
{HotKeyFunction.InspectHoveredControl,new(Key.None, KeyModifiers.Shift | KeyModifiers.Control) },
{HotKeyFunction.FramesFreeze,new(Key.S, KeyModifiers.Alt) },
{HotKeyFunction.FramesUnfreeze,new(Key.D, KeyModifiers.Alt) },
{HotKeyFunction.TogglePopupFreeze,new(Key.F, KeyModifiers.Alt | KeyModifiers.Control) },
{HotKeyFunction.ScreenshotSelectedControl,new(Key.F8) },
};
/// <summary>
/// Gets or sets the key gesture used to open DevTools.
/// </summary>
public KeyGesture Gesture
{
get => _hotkeyConfig.TryGetValue(HotKeyFunction.LaunchDevTools, out var gesture)
? gesture
: DefaultLaunchDevToolsGesture;
init => _hotkeyConfig[HotKeyFunction.LaunchDevTools] = value;
}
public IReadOnlyDictionary<HotKeyFunction, KeyGesture> HotKeyConfig
{
get => _hotkeyConfig;
init
{
// Merge
foreach (var kvp in value)
{
_hotkeyConfig[kvp.Key] = kvp.Value;
}
}
}
...
} using like: var options = new DevToolsOptions()
{
HotKeyConfig = new Dictionary<HotKeyFunction, KeyGesture>
{
{ HotKeyFunction.LaunchDevTools , new(Key.F24) },
{ HotKeyFunction.InspectHoveredControl, new(Key.None, KeyModifiers.Shift | KeyModifiers.Control) },
},
}; |
We probably won't have this much of hotkeys to justify a dictionary. A class looks more than enough here. |
What does the pull request do?
Fixes #15390
Adds a HotKey page because there's no in-app discoverability of DevTools hotkeys. Otherwise, the user must check docs.
What is the updated/expected behavior with this PR?
Simple display of hotkeys, no mutability. Does not display the launch hotkey as that is mutable via
DevToolOptions
and would require some wiring. If the user doesn't know that hotkey, then how are they in DevTools to begin with?Very recently, the "Styles" snapshot action was modified to "Value Frames". I reflect this in the hotkey descriptions, but other places still use Styles, including the DevTools docs page.
How was the solution implemented (if it's not obvious)?
Adds an invisible
TabStripItem
for theHotKeys
page to avoid visual crowding and avoid adding more complex navigation.Checklist