Multiline edit everywhere (#15216)

This commit is contained in:
Morb
2023-04-14 12:57:47 -07:00
committed by GitHub
parent b3ed09a3db
commit 2eb2ded7f3
12 changed files with 73 additions and 37 deletions

View File

@@ -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);
}
}
}

View File

@@ -10,15 +10,15 @@
<PanelContainer Name="PaperBackground" StyleClasses="PaperDefaultBorder" VerticalExpand="True" HorizontalExpand="True">
<ScrollContainer Name="ScrollingContents" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False">
<PanelContainer Name="PaperContent" VerticalExpand="True" HorizontalExpand="True" MaxWidth="600">
<BoxContainer Orientation="Vertical" VerticalAlignment="Top">
<BoxContainer Orientation="Vertical" VerticalAlignment="Stretch">
<TextureButton Name="HeaderImage" HorizontalAlignment="Center" VerticalAlignment="Top" MouseFilter="Ignore"/>
<Control Name="TextAlignmentPadding" VerticalAlignment="Top" />
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor"
VerticalAlignment="Top" HorizontalAlignment="Center"/>
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel"
VerticalAlignment="Top" HorizontalExpand="True">
<LineEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
</PanelContainer>
</BoxContainer>
<BoxContainer Name="StampDisplay" Orientation="Vertical" VerticalAlignment="Bottom" Margin="6"/>