using JetBrains.Annotations;
using Robust.Client.UserInterface.Controls;
-using Robust.Shared.Input;
using Robust.Shared.Utility;
using static Content.Shared.Paper.SharedPaperComponent;
_window = new PaperWindow();
_window.OnClose += Close;
- _window.Input.OnKeyBindDown += args => // Solution while TextEdit don't have events
- {
- if (args.Function == EngineKeyFunctions.MultilineTextSubmit)
- {
- var text = Rope.Collapse(_window.Input.TextRope);
- Input_OnTextEntered(text);
- args.Handle();
- }
- };
+ _window.OnSaved += Input_OnTextEntered;
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
using Content.Shared.Paper;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
+using Robust.Client.Input;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
using Robust.Client.UserInterface.RichText;
+using Robust.Shared.Input;
namespace Content.Client.Paper.UI
{
[GenerateTypedNameReferences]
public sealed partial class PaperWindow : BaseWindow
{
+ [Dependency] private readonly IInputManager _inputManager = default!;
+
private static Color DefaultTextColor = new(25, 25, 25);
// <summary>
typeof(ItalicTag)
};
+ public event Action<string>? OnSaved;
+
public PaperWindow()
{
+ IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
// We can't configure the RichTextLabel contents from xaml, so do it here:
// Hook up the close button:
CloseButton.OnPressed += _ => Close();
+
+ Input.OnKeyBindDown += args => // Solution while TextEdit don't have events
+ {
+ if (args.Function == EngineKeyFunctions.MultilineTextSubmit)
+ {
+ RunOnSaved();
+ args.Handle();
+ }
+ };
+
+ SaveButton.OnPressed += _ =>
+ {
+ RunOnSaved();
+ };
+
+ SaveButton.Text = Loc.GetString("paper-ui-save-button",
+ ("keybind", _inputManager.GetKeyFunctionButtonString(EngineKeyFunctions.MultilineTextSubmit)));
}
/// <summary>
bool isEditing = state.Mode == SharedPaperComponent.PaperAction.Write;
bool wasEditing = InputContainer.Visible;
InputContainer.Visible = isEditing;
+ EditButtons.Visible = isEditing;
var msg = new FormattedMessage();
msg.AddMarkupPermissive(state.Text);
}
return mode & _allowedResizeModes;
}
+
+ private void RunOnSaved()
+ {
+ OnSaved?.Invoke(Rope.Collapse(Input.TextRope));
+ }
}
}