#C# OnGuiInput only detecting mouse movement

3 messages · Page 1 of 1 (latest)

void aurora
#

ok, so my card state won't detect any mouse button presses (I've double checked that I named them correctly in the project settings) for this specific method, but it does detect mousemotion

{
    var mouseMotion = e is InputEventMouseMotion;
    var mouseAtBottom = cardUi.GetGlobalMousePosition().Y < MOUSE_Y_SNAPBACK_THRESHOLD;
    bool cancel = e.IsActionPressed("rmb");
    bool confirmed = e.IsActionReleased("lmb") || e.IsActionPressed("lmb");
    //aim cancelled
    if ((mouseMotion && mouseAtBottom) || cancel)
    {
        EmitSignal(CardState.SignalName.TransitionRequested, this, (int)State.BASE);
    }
    //otherwise we release the card
    else if (confirmed)
    {
        GetViewport().SetInputAsHandled();
        EmitSignal(CardState.SignalName.TransitionRequested, this, (int)State.RELEASED);
    }
}```
basically the cancel OR confirmed variables are never true..... 


actually, I'm now realizing that my input event is literally only registering on mouse motion for this method. (I added `GD.Print(e.AsText())` to the top of the method)
this doesn't help me fix it, but it is curious
#

looks like I needed to set this as OnInput instead of OnGuiInput because otherwise it only detected it when I did something within the cardUi.

naive sky
#

OnInput and OnGuiInput are very different. GUI input does only detect mouse events, and only if they are "on the control node". it should however also include mouse button preses, even when using input actions to check for it. That's at least how it works in GDScript, but it would be weird if it works differently for C#.