Multiline edit everywhere (#15216)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.Paper.SharedPaperComponent;
|
||||
|
||||
namespace Content.Client.Paper.UI
|
||||
@@ -23,7 +23,15 @@ namespace Content.Client.Paper.UI
|
||||
|
||||
_window = new PaperWindow();
|
||||
_window.OnClose += Close;
|
||||
_window.Input.OnTextEntered += Input_OnTextEntered;
|
||||
_window.Input.OnKeyBindDown += args => // Solution while TextEdit don't have events
|
||||
{
|
||||
if (args.Function == EngineKeyFunctions.TextSubmit)
|
||||
{
|
||||
var text = Rope.Collapse(_window.Input.TextRope);
|
||||
Input_OnTextEntered(text);
|
||||
args.Handle();
|
||||
}
|
||||
};
|
||||
|
||||
if (entityMgr.TryGetComponent<PaperVisualsComponent>(Owner.Owner, out var visuals))
|
||||
{
|
||||
@@ -39,15 +47,16 @@ namespace Content.Client.Paper.UI
|
||||
_window?.Populate((PaperBoundUserInterfaceState) state);
|
||||
}
|
||||
|
||||
private void Input_OnTextEntered(LineEdit.LineEditEventArgs obj)
|
||||
private void Input_OnTextEntered(string text)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(obj.Text))
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
SendMessage(new PaperInputTextMessage(obj.Text));
|
||||
SendMessage(new PaperInputTextMessage(text));
|
||||
|
||||
if (_window != null)
|
||||
{
|
||||
_window.Input.Text = string.Empty;
|
||||
_window.Input.TextRope = Rope.Leaf.Empty;
|
||||
_window.Input.CursorPosition = new TextEdit.CursorPos(0, TextEdit.LineBreakBias.Top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user