1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-09 19:18:44 +02:00

Fixed TextInput and Slider still reacting to input when they are selected, but not part of the active root

This commit is contained in:
Ell 2023-04-24 11:15:16 +02:00
parent b289bbd98e
commit 230f2e954c
4 changed files with 10 additions and 3 deletions

View file

@ -44,6 +44,7 @@ Fixes
- Fixed images not updating their hidden state properly when the displayed texture changes
- Fixed AutoInline elements overflowing into their parent if it's taller
- Fixed Paragraph and Checkbox not reacting to SquishingGroup sizing properly
- Fixed TextInput and Slider still reacting to input when they are selected, but not part of the active root
## 6.1.0

View file

@ -320,9 +320,15 @@ namespace MLEM.Ui.Elements {
public bool IsMouseOver => this.Controls.MousedElement == this || this.Controls.TouchedElement == this;
/// <summary>
/// Returns whether this element is its <see cref="Root"/>'s <see cref="RootElement.SelectedElement"/>.
/// Note that, unlike <see cref="IsSelectedActive"/>, this property will be <see langword="true"/> even if this element's <see cref="Root"/> is not the <see cref="UiControls.ActiveRoot"/>.
/// </summary>
public bool IsSelected => this.Root.SelectedElement == this;
/// <summary>
/// Returns whether this element is its <see cref="Controls"/>'s <see cref="UiControls.SelectedElement"/>.
/// Note that <see cref="IsSelected"/> can be used to query whether this element is its <see cref="Root"/>'s <see cref="RootElement.SelectedElement"/> instead.
/// </summary>
public bool IsSelectedActive => this.Controls.SelectedElement == this;
/// <summary>
/// Returns whether this element's <see cref="SetAreaDirty"/> method has been recently called and its area has not been updated since then using <see cref="UpdateAreaIfDirty"/> or <see cref="ForceUpdateArea"/>.
/// </summary>
public bool AreaDirty { get; private set; }

View file

@ -29,7 +29,7 @@ namespace MLEM.Ui.Elements {
public override void Update(GameTime time) {
base.Update(time);
if (this.IsSelected) {
if (this.IsSelectedActive) {
if (this.CurrentValue > 0 && this.Controls.LeftButtons.TryConsumePressed(this.Input, this.Controls.GamepadIndex)) {
this.CurrentValue -= this.StepPerScroll;
} else if (this.CurrentValue < this.MaxValue && this.Controls.RightButtons.TryConsumePressed(this.Input, this.Controls.GamepadIndex)) {

View file

@ -192,7 +192,7 @@ namespace MLEM.Ui.Elements {
this.SetText(this.Multiline ? result : result.Replace('\n', ' '), true);
};
this.OnTextInput += (element, key, character) => {
if (this.IsSelected && !this.IsHidden)
if (this.IsSelectedActive && !this.IsHidden)
this.textInput.OnTextInput(key, character);
};
this.OnDeselected += e => this.CaretPos = 0;
@ -209,7 +209,7 @@ namespace MLEM.Ui.Elements {
/// <inheritdoc />
public override void Update(GameTime time) {
base.Update(time);
if (this.IsSelected && !this.IsHidden)
if (this.IsSelectedActive && !this.IsHidden)
this.textInput.Update(time, this.Input);
}