Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Removed Focused loss triggering button Release #2549

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TranquilAbyss
Copy link
Contributor

@TranquilAbyss TranquilAbyss commented Dec 8, 2024

PR Details

On deselecting Edit Text, via myEditTextElement.IsSelectionActive = false;, focus was lost which triggered two behaviors which both triggered button releases. One mouse and keyboard and the other just the mouse release. This PR affects the following inputs: STRIDE_UI_WINFORMS and STRIDE_UI_WPF.

I have checked the box that this maybe a breaking change due to the following comment in the removed code.
// Release keys/buttons when control focus is lost (this prevents some keys getting stuck when a focus loss happens when moving the camera)
I tried to test moving the camera around while typing in an EditText, but was not able to reproduce a key or mouse button press being stuck.

My reasoning for a possibly breaking change is that due to

  • The lack of test coverage or documentation for how to recreate the original issue being fixed by UIControlOnLostFocus and UIControlOnLostFocus.
  • Having buttons automatically released on focus change can interrupt behaviors like game state changes (managing hotkeys while in menus) and potentially drag and drop functionalities.
  • I cannot think of a use case where we want UI focus to release user/player Input controls.
  • I also checked the SDL and did not see this, button release on focus loss, functionality there.

If more knowledge on the original goals of the functions UIControlOnLostFocus and UIControlOnLostFocus are known, I will revised this PR to address it.

Related Issue

#2084

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Test Script

Here is the script I used to test if the "Mouse Button Released" was happening on Mouse Press or Release.

using Stride.Engine;
using Stride.UI;
using Stride.UI.Controls;
using System.Diagnostics;
using Stride.Input;
using Stride.Core.Mathematics;
using System;

public class Script : SyncScript
{
    public UIComponent page;
    EditText editText;

    public override void Start()
    {
        editText = page.Page.RootElement.FindVisualChildOfType<EditText>("EditText");
    }

    public override void Update()
    {
        if (Input.IsMouseButtonPressed(MouseButton.Left))
        {
            editText.IsSelectionActive = false;
        }
        else if (Input.IsMouseButtonReleased(MouseButton.Left)) 
        {
            Debug.WriteLine("Mouse Button Released");
            DebugText.Print("Mouse Button Released", new Int2(10, 10), null, new TimeSpan(0, 0, 0, 0, 15));
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant