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

PassThroughInputManager syncs key presses even if they were handled #1966

Open
smoogipoo opened this issue Oct 31, 2018 · 2 comments · May be fixed by #6221
Open

PassThroughInputManager syncs key presses even if they were handled #1966

smoogipoo opened this issue Oct 31, 2018 · 2 comments · May be fixed by #6221

Comments

@smoogipoo
Copy link
Contributor

smoogipoo commented Oct 31, 2018

In PassThroughInputManager.Update() it syncs the state from the parenting input manager.

For mouse input, only released buttons are handled.
For keyboard input, pressed and released buttons are handled.

This has the effect that if a Drawable handles KeyDown() at a higher point in the hierarchy, the button press will also be handled by every PassThroughInputManager in the draw hierarchy when they sync.

Test case:

public class TestCaseScratch : TestCase
{
    public TestCaseScratch()
    {
        Children = new Drawable[]
        {
            new PassThroughInputManager
            {
                RelativeSizeAxes = Axes.Both,
                UseParentInput = true,
                Child = new InputBox { RelativeSizeAxes = Axes.Both }
            },
            new HiddenInputHandler { RelativeSizeAxes = Axes.Both }
        };
    }

    private class InputBox : Box
    {
        protected override bool OnKeyDown(KeyDownEvent e)
        {
            Colour = Color4.Red;
            return true;
        }

        protected override bool OnKeyUp(KeyUpEvent e)
        {
            Colour = Color4.White;
            return true;
        }
    }

    private class HiddenInputHandler : Box
    {
        public HiddenInputHandler()
        {
            Alpha = 0;
            AlwaysPresent = true;
        }

        protected override bool Handle(UIEvent e) => true;
    }
}
@UselessToucan
Copy link
Contributor

I have a couple of questions.
Lets say we have the scene graph.
image

  1. Do I understand correctly that PassThroughInputManager should sync input state changes related to Container B and Container C(including their children)?
  2. Do I understand correctly that PassThroughInputManager should ignore input state changes out of its scope? For example, input state changes related to Container A.
  3. Do I understand correctly that the relationship between PassThroughInputManager and parent InputManager is many to one? I mean, we can have multiple PassThroughInputManager which will sync with one parent InputManager.

@smoogipoo
Copy link
Contributor Author

smoogipoo commented Nov 12, 2018

  1. Not sure what you mean by this. Syncing input state changes related to its own children?
  2. Container B/C should still see that key A is down even if Container A handled it, if they query GetParentInputManager().CurrentState.
  3. Yes

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