Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into gametitle-public
Browse files Browse the repository at this point in the history
  • Loading branch information
VasilisThePikachu committed Sep 30, 2024
2 parents f4b1752 + ea02260 commit 530499e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ END TEMPLATE-->
### New features

* `RequiredMemberAttribute` and `SetsRequiredMembersAttribute` have been added to the sandbox whitelist. I.e., you can now use the `required` keyword in client/shared code.
* Added `LineEdit.SelectAllOnFocus`.
* ``Gametitle``,``WindowIconSet`` and ``SplashLogo`` are exposed in IGameController. These will return said information set game options or whatever is set in manifest.yml.

### Bugfixes
Expand Down
23 changes: 22 additions & 1 deletion Robust.Client/UserInterface/Controls/LineEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public class LineEdit : Control
private TimeSpan? _lastClickTime;
private Vector2? _lastClickPosition;

// Keep track of the frame on which we got focus, so we can implement SelectAllOnFocus properly.
// Otherwise, there's no way to keep track of whether the KeyDown is the one that focused the text box,
// to avoid text selection stomping on the behavior.
// This isn't a great way to do it.
// A better fix would be to annotate all input events with some unique sequence ID,
// and expose the input event that focused the control in KeyboardFocusEntered.
// But that sounds like a refactor I'm not doing today.
private uint _focusedOnFrame;

private bool IsPlaceHolderVisible => !(HidePlaceHolderOnFocus && HasKeyboardFocus()) && string.IsNullOrEmpty(_text) && _placeHolder != null;

public event Action<LineEditEventArgs>? OnTextChanged;
Expand Down Expand Up @@ -190,6 +199,11 @@ public int SelectionStart

public bool IgnoreNext { get; set; }

/// <summary>
/// If true, all the text in the LineEdit will be automatically selected whenever it is focused.
/// </summary>
public bool SelectAllOnFocus { get; set; }

private (int start, int length)? _imeData;


Expand Down Expand Up @@ -709,7 +723,7 @@ async void DoPaste()

args.Handle();
}
else
else if (!(SelectAllOnFocus && _focusedOnFrame == _timing.CurFrame))
{
_lastClickTime = _timing.RealTime;
_lastClickPosition = args.PointerLocation.Position;
Expand Down Expand Up @@ -868,6 +882,13 @@ protected internal override void KeyboardFocusEntered()
{
_clyde.TextInputStart();
}

_focusedOnFrame = _timing.CurFrame;
if (SelectAllOnFocus)
{
CursorPosition = _text.Length;
SelectionStart = 0;
}
}

protected internal override void KeyboardFocusExited()
Expand Down

0 comments on commit 530499e

Please sign in to comment.