Pointer up is not being generated

Hello UI Toolkit experts,

at the moment I am trying to create some sort of radial menu for my game. It will work like this:

The user holds the mouse button, the menu appears. He hovers over a menu option - it is being selected by evaluating the mouse position relative to the center of the menu. When the user lets go of the mouse button, the selected option is being confirmed and the menu is hidden again.

The steps:

  1. The game detects that the user has long-pressed somewhere within a behavior.
  2. The behavior gets disabled, the UI, just 5 plain visual elements at the moment, is made visible.
  3. While the user still holds down the mouse button, the mouse is captured by the radial menu.
  4. The mouse-move-events are generated and are being captured properly by the radial menu.
  5. When releasing the mouse, no mouse-up-event is being received. I have to press the button again and release it to make it count. The pointer up event is only being generated when there is a pointer down event before.


Is this a bug? How can I make the event system aware of the fact that there has been a pointer down event sometime before?

BR,

Andrej

PS: Maybe some code might help:
This is called when the behavior detects the long press:

public void ShowContextMenu(int mouseButton)
    {
        radialContextMenu.Show(defaultInputHandler.activeCamera, mouseButton);
        enabled = false;
    }

This is how the mouse is captured by the UI:

public void Show(ACam activeCamera, int mouseButton)
    {
        this.mouseButton = mouseButton;

        center.CaptureMouse();
        center.style.display = DisplayStyle.Flex;
    }

And this is the method that is called when the mouse-up-event is received:

private void ConfirmSelection(MouseUpEvent e)
    {
        if(e.button != mouseButton) return;
        center.ReleaseMouse();
        center.style.display = DisplayStyle.None;
        inputStateMachine.OnContextMenuOptionChosen();
        Debug.Log("option chosen!");
    }

This is where my non-ui input handling is reactivated:

public void OnContextMenuOptionChosen()
    {
        enabled = true;
        currentState = defaultInputHandler;
    }

Hi. Is this a runtime menu, or a menu from an EditorWindow? If runtime, what other objects are present in your scene, apart from the UIDocument (an EventSystem for example)? Maybe I could help if I had a look at a zip of your project. I’ve seen something that looks like what you’re describing recently, but only in specific circumstances, that’s why I’m asking for more context.

Hello Benoit,
thank you for your response. This happens with my runtime radial menu.
I submitted my project as a bug (Case 1366568).
I’m looking forward to a fix :slight_smile:

BR,

Andrej

PS: I tried to reproduce the bug in a fresh project but it worked as intended. If you also need that ‘minimal’ project for comparison, I can share that with you too.

Hello,
it has been a while. Any news on this bug?

BR,

Andrej

Hi, I have a similar use-case as OP. As uBenoitA hinted at, it happens if you have an EventSystem present and enabled while you are using UI Toolkit. I have to do that as I need to use features not available to UI Toolkit yet for some UI elements.
uBenoitA posted a workaround here: UIToolkit compatibility issue on Mobile with the new Input System which works for me:
EventSystem.SetUITookitEventSystemOverride(null, false, false);

I am working with Unity 2021.1.21f1 and only enabled the old Input System.