diff --git a/docs/reference/first-release-scene-control.md b/docs/reference/first-release-scene-control.md index a131a991..dfbe7317 100644 --- a/docs/reference/first-release-scene-control.md +++ b/docs/reference/first-release-scene-control.md @@ -36,8 +36,8 @@ The Windows Studio footer groups Graphics and Outputs on the left, Take/FTB on t health/audio row. Output option flyouts remain available. Edit Tiles on a Tiles scene cues that scene to Preview and opens its wall inspector; it never Takes. -Ctrl+Enter invokes the existing Take command in Studio. Ctrl+Shift+B invokes FTB. -Both shortcuts ignore text-entry controls. Existing graphics F-key mappings and +Spacebar invokes the existing Take command in Studio; Ctrl+Enter remains an alternate. +Ctrl+Shift+B invokes FTB. These shortcuts ignore text-entry controls. Existing graphics F-key mappings and remote `transport.take` remain unchanged. Companion discovers `transport.ftb.toggle` and `transport.ftb.set(enabled)` from the action manifest; its FTB preset lights from `programBlackout` feedback. Use the idempotent set action when retrying requests. diff --git a/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.TransportHotkeys.cs b/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.TransportHotkeys.cs index 2ce6ba42..e25f2d88 100644 --- a/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.TransportHotkeys.cs +++ b/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.TransportHotkeys.cs @@ -1,6 +1,10 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Input; using Windows.System; +using Windows.UI.Core; namespace CoreVideoPro.WinUI.Views; @@ -10,6 +14,10 @@ public sealed partial class StudioWorkspace private void AttachTransportHotkeys() { + // Preview events precede a focused button's built-in Space activation. + // A normal accelerator on the parent loses to the transition flyout button. + PreviewKeyDown += OnTransportPreviewKeyDown; + PreviewKeyUp += OnTransportPreviewKeyUp; Add(VirtualKey.Enter, VirtualKeyModifiers.Control, false); Add(VirtualKey.B, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, true); void Add(VirtualKey key, VirtualKeyModifiers modifiers, bool blackout) @@ -29,4 +37,38 @@ void Add(VirtualKey key, VirtualKeyModifiers modifiers, bool blackout) KeyboardAccelerators.Add(accelerator); } } + + private bool _spaceTakeCaptured; + + private void OnTransportPreviewKeyDown(object sender, KeyRoutedEventArgs args) + { + if (args.Key != VirtualKey.Space) return; + var modified = IsDown(VirtualKey.Control) || IsDown(VirtualKey.Shift) || + IsDown(VirtualKey.Menu) || IsDown(VirtualKey.LeftWindows) || IsDown(VirtualKey.RightWindows); + var focus = XamlRoot is null ? null : FocusManager.GetFocusedElement(XamlRoot) as DependencyObject; + if (ViewModel is not { IsStudioTab: true } vm || modified || IsTextEntry(focus)) return; + // Consume even when Take is unavailable: Space must never open a flyout + // or toggle an output because the focused control happened to change. + args.Handled = true; + _spaceTakeCaptured = true; + if (!args.KeyStatus.WasKeyDown && vm.TakeCommand.CanExecute(null)) + vm.TakeCommand.Execute(null); + } + + private void OnTransportPreviewKeyUp(object sender, KeyRoutedEventArgs args) + { + if (args.Key != VirtualKey.Space || !_spaceTakeCaptured) return; + args.Handled = true; + _spaceTakeCaptured = false; + } + + private static bool IsDown(VirtualKey key) => + InputKeyboardSource.GetKeyStateForCurrentThread(key).HasFlag(CoreVirtualKeyStates.Down); + + private static bool IsTextEntry(DependencyObject? focus) + { + for (var current = focus; current is not null; current = VisualTreeHelper.GetParent(current)) + if (current is TextBox or RichEditBox or AutoSuggestBox or NumberBox or PasswordBox) return true; + return false; + } } diff --git a/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.xaml b/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.xaml index 5820eb2a..fd9ea037 100644 --- a/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.xaml +++ b/native-shell/CoreVideoPro.WinUI/Views/StudioWorkspace.xaml @@ -1209,7 +1209,7 @@