Upgraded ChatBox and fixed FocusChat hotkey
Upgraded ChatBox to use Keybinds. Put cursor at the end of text of ChatBox history. Fixed FocusChat hotkey getting called when typing in a LineEdit. Added Keybinds.
This commit is contained in:
@@ -8,6 +8,7 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Input;
|
||||
|
||||
namespace Content.Client.Chat
|
||||
{
|
||||
@@ -84,7 +85,7 @@ namespace Content.Client.Chat
|
||||
vBox.AddChild(contentMargin);
|
||||
|
||||
Input = new LineEdit();
|
||||
Input.OnKeyDown += InputKeyDown;
|
||||
Input.OnKeyBindDown += InputKeyBindDown;
|
||||
Input.OnTextEntered += Input_OnTextEntered;
|
||||
vBox.AddChild(Input);
|
||||
|
||||
@@ -133,16 +134,15 @@ namespace Content.Client.Chat
|
||||
Input.GrabKeyboardFocus();
|
||||
}
|
||||
|
||||
private void InputKeyDown(GUIKeyEventArgs e)
|
||||
private void InputKeyBindDown(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
if (e.Key == Keyboard.Key.Escape)
|
||||
if (args.Function == EngineKeyFunctions.TextReleaseFocus)
|
||||
{
|
||||
Input.ReleaseKeyboardFocus();
|
||||
e.Handle();
|
||||
args.Handle();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Keyboard.Key.Up)
|
||||
else if (args.Function == EngineKeyFunctions.TextHistoryPrev)
|
||||
{
|
||||
if (_inputIndex == -1 && _inputHistory.Count != 0)
|
||||
{
|
||||
@@ -158,12 +158,12 @@ namespace Content.Client.Chat
|
||||
{
|
||||
Input.Text = _inputHistory[_inputIndex];
|
||||
}
|
||||
Input.CursorPos = Input.Text.Length;
|
||||
|
||||
e.Handle();
|
||||
args.Handle();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Keyboard.Key.Down)
|
||||
else if (args.Function == EngineKeyFunctions.TextHistoryNext)
|
||||
{
|
||||
if (_inputIndex == 0)
|
||||
{
|
||||
@@ -176,8 +176,9 @@ namespace Content.Client.Chat
|
||||
_inputIndex--;
|
||||
Input.Text = _inputHistory[_inputIndex];
|
||||
}
|
||||
Input.CursorPos = Input.Text.Length;
|
||||
|
||||
e.Handle();
|
||||
args.Handle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Client.Chat;
|
||||
using Content.Client.Interfaces;
|
||||
@@ -18,6 +18,7 @@ using Robust.Shared.Input;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -188,11 +189,7 @@ namespace Content.Client.GameTicking
|
||||
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||
InputCmdHandler.FromDelegate(session =>
|
||||
{
|
||||
_lobby.Chat.Input.IgnoreNext = true;
|
||||
_lobby.Chat.Input.GrabKeyboardFocus();
|
||||
}));
|
||||
InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat)));
|
||||
|
||||
_updateLobbyUi();
|
||||
|
||||
@@ -237,19 +234,25 @@ namespace Content.Client.GameTicking
|
||||
_lobby = null;
|
||||
}
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||
InputCmdHandler.FromDelegate(session =>
|
||||
{
|
||||
_gameChat.Input.IgnoreNext = true;
|
||||
_gameChat.Input.GrabKeyboardFocus();
|
||||
}));
|
||||
|
||||
_gameChat = new ChatBox();
|
||||
_userInterfaceManager.StateRoot.AddChild(_gameChat);
|
||||
_userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
|
||||
_chatManager.SetChatBox(_gameChat);
|
||||
_gameChat.DefaultChatFormat = "say \"{0}\"";
|
||||
_gameChat.Input.PlaceHolder = _localization.GetString("Say something! [ for OOC");
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||
InputCmdHandler.FromDelegate(s => _focusChat(_gameChat)));
|
||||
}
|
||||
|
||||
private void _focusChat(ChatBox chat)
|
||||
{
|
||||
if (_userInterfaceManager.KeyboardFocused != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
chat.Input.IgnoreNext = true;
|
||||
chat.Input.GrabKeyboardFocus();
|
||||
}
|
||||
|
||||
private enum TickerState
|
||||
|
||||
@@ -99,4 +99,35 @@ binds:
|
||||
- function: MouseMiddle
|
||||
type: state
|
||||
key: MouseMiddle
|
||||
canFocus: true
|
||||
canFocus: true
|
||||
- function: TextCursorLeft
|
||||
type: state
|
||||
key: Left
|
||||
- function: TextCursorRight
|
||||
type: state
|
||||
key: Right
|
||||
- function: TextBackspace
|
||||
type: state
|
||||
key: BackSpace
|
||||
- function: TextSubmit
|
||||
type: state
|
||||
key: Return
|
||||
- function: TextSubmit
|
||||
type: state
|
||||
key: NumpadEnter
|
||||
- function: TextPaste
|
||||
type: state
|
||||
key: V
|
||||
mod1: Control
|
||||
- function: TextHistoryPrev
|
||||
type: state
|
||||
key: Up
|
||||
- function: TextHistoryNext
|
||||
type: state
|
||||
key: Down
|
||||
- function: TextReleaseFocus
|
||||
type: state
|
||||
key: Escape
|
||||
- function: TextScrollToBottom
|
||||
type: state
|
||||
key: PageDown
|
||||
Submodule RobustToolbox updated: 6c6764593b...7374fc5894
Reference in New Issue
Block a user