diff --git a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs index 050262cc99..41c3ac76f9 100644 --- a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs +++ b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs @@ -1,10 +1,8 @@ using System.Linq; using Content.Client.Administration.Systems; using Content.Client.UserInterface.Controls; -using Content.Client.Verbs; using Content.Client.Verbs.UI; using Content.Shared.Administration; -using Content.Shared.Input; using Robust.Client.AutoGenerated; using Robust.Client.Graphics; using Robust.Client.UserInterface; @@ -39,6 +37,7 @@ namespace Content.Client.Administration.UI.CustomControls RobustXamlLoader.Load(this); // Fill the Option data PlayerListContainer.ItemPressed += PlayerListItemPressed; + PlayerListContainer.ItemKeyBindDown += PlayerListItemKeyBindDown; PlayerListContainer.GenerateItem += GenerateButton; PopulateList(_adminSystem.PlayerList); FilterLineEdit.OnTextChanged += _ => FilterList(); @@ -50,18 +49,27 @@ namespace Content.Client.Administration.UI.CustomControls { if (args == null || data is not PlayerListData {Info: var selectedPlayer}) return; - if (args.Event.Function == EngineKeyFunctions.UIClick) - { - OnSelectionChanged?.Invoke(selectedPlayer); - // update label text. Only required if there is some override (e.g. unread bwoink count). - if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label) - label.Text = GetText(selectedPlayer); - } - else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.NetEntity != null) - { - _uiManager.GetUIController().OpenVerbMenu(selectedPlayer.NetEntity.Value, true); - } + if (args.Event.Function != EngineKeyFunctions.UIClick) + return; + + OnSelectionChanged?.Invoke(selectedPlayer); + + // update label text. Only required if there is some override (e.g. unread bwoink count). + if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label) + label.Text = GetText(selectedPlayer); + } + + private void PlayerListItemKeyBindDown(GUIBoundKeyEventArgs? args, ListData? data) + { + if (args == null || data is not PlayerListData { Info: var selectedPlayer }) + return; + + if (args.Function != EngineKeyFunctions.UIRightClick || selectedPlayer.NetEntity == null) + return; + + _uiManager.GetUIController().OpenVerbMenu(selectedPlayer.NetEntity.Value, true); + args.Handle(); } public void StopFiltering() diff --git a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs index 3f5df2cf00..dcb184b308 100644 --- a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs @@ -1,7 +1,6 @@ using Content.Client.Station; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; -using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Map.Components; @@ -15,7 +14,7 @@ public sealed partial class ObjectsTab : Control private readonly List _objects = new(); private List _selections = new(); - public event Action? OnEntryPressed; + public event Action? OnEntryKeyBindDown; public ObjectsTab() { @@ -82,7 +81,7 @@ public sealed partial class ObjectsTab : Control var ctrl = new ObjectsTabEntry(name, entity); _objects.Add(ctrl); ObjectList.AddChild(ctrl); - ctrl.OnPressed += args => OnEntryPressed?.Invoke(args); + ctrl.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(ctrl, args); } } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index 1190a4c329..33a1d2361f 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab private bool _ascending = true; private bool _showDisconnected; - public event Action? OnEntryPressed; + public event Action? OnEntryKeyBindDown; public PlayerTab() { @@ -123,7 +123,7 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab player.Connected, player.PlaytimeString); entry.PlayerEntity = player.NetEntity; - entry.OnPressed += args => OnEntryPressed?.Invoke(args); + entry.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(entry, args); entry.ToolTip = Loc.GetString("player-tab-entry-tooltip"); PlayerList.AddChild(entry); diff --git a/Content.Client/UserInterface/Controls/ListContainer.cs b/Content.Client/UserInterface/Controls/ListContainer.cs index c66ef33d3f..05ae0a4bb1 100644 --- a/Content.Client/UserInterface/Controls/ListContainer.cs +++ b/Content.Client/UserInterface/Controls/ListContainer.cs @@ -23,6 +23,7 @@ public sealed class ListContainer : Control public bool Toggle { get; set; } public Action? GenerateItem; public Action? ItemPressed; + public Action? ItemKeyBindDown; public IReadOnlyList Data => _data; private const int DefaultSeparation = 3; @@ -135,6 +136,11 @@ public sealed class ListContainer : Control ItemPressed?.Invoke(args, button.Data); } + private void OnItemKeyBindDown(ListContainerButton button, GUIBoundKeyEventArgs args) + { + ItemKeyBindDown?.Invoke(args, button.Data); + } + [Pure] private Vector2 GetScrollValue() { @@ -256,6 +262,7 @@ public sealed class ListContainer : Control { button = new ListContainerButton(data); button.OnPressed += OnItemPressed; + button.OnKeyBindDown += args => OnItemKeyBindDown(button, args); button.ToggleMode = Toggle; button.Group = _buttonGroup; diff --git a/Content.Client/UserInterface/Systems/Admin/AdminUIController.cs b/Content.Client/UserInterface/Systems/Admin/AdminUIController.cs index acb79cf301..a7ece3714d 100644 --- a/Content.Client/UserInterface/Systems/Admin/AdminUIController.cs +++ b/Content.Client/UserInterface/Systems/Admin/AdminUIController.cs @@ -13,6 +13,7 @@ using Content.Shared.Input; using JetBrains.Annotations; using Robust.Client.Console; using Robust.Client.Input; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controls; using Robust.Shared.Input; @@ -97,8 +98,8 @@ public sealed class AdminUIController : UIController, IOnStateEntered