discarding non purposeful mouse clicks inside a widget in order not to process them

hi

i generally use mouse left and right click for various controls
if you accidently and un-purposefully click inside of of a widget i created, it interprets it as a control click because it is without purpose inside the widget, and has purpose outside of the widget
what would be a good way to know if a mouse click was inside a widget without intent, so as to simply discard it rather than process it
even a broad outline would be helpful

thanks

Hey there @barbrian0723! Just to clarify the question, you want a method to recognize when an interaction with a widget is unintentional? In most cases, it’s usually best to design your UI/UX around the inability to receive miss-inputs like that, or limit them by keeping the actual interactive portions out of the way of general play. For example, an RTS game would have small accurate buttons for anything that could be disruptive, and larger surface area buttons for things that are frequently selected.

1 Like

yes this is unintentional or non purposeful mouse clicks on a widget

when no widget is open, i process mouse left and right clicks to initiate certain functions and functionality as part of ui
when a widget is open, purposeful and intentional mouse clicks are not a problem because they initiate the corresponding action and that is it

but i accidentally discovered that non purposeful mouse clicks inside an open widget has the adverse affect of triggering functionality when they should not because the mouse click apart from the widget has meaning and because the widget does not consume the mouse click because it is not intentional or purposeful

i discovered this by accident after some time by clicking by accident within a widget and because i did not click anything meaningful in the widget, the mouse click was registered as as something apart from the widget as if the widget was not open

so i really need to discard cases of mouse clicks inside a widget that has no purpose and are not consumed so that they do not register as a mouse click when no widget is open

first of all, how would one know if a widget, but nothing in particular like a sub widget (button etc) on the widget was clicked?

If a widget has no interactable portion, and it’s not say a button you’re interacting with, turning off the “isFocusable” which will stop it from eating other inputs after you click it, but it will still absorb the mouse input. You can stop the mouse input portion with setting the non-interactable elements to Not Hit Testable:

Though detecting true accidental hits on real buttons/interactables can be an entirely different task that most try to avoid.

1 Like

it seems to work if i use use the override on mouse button down to simply discard non purposeful mouse clicks within the widget so that they dont bubble up beyond the widget

Technically if input isn’t consumed you still bubble, but its pointless.

Only add code for the mouse click “listen” to the widget.
That way when you add the widget component (normally a custom widget button you use everywhere so that the base underlying functions are all identical everywhere) is present, it’ll automatically know if its clicked.

You may go as far as implementing interfaces, but i cant recall if the wisget stuff does indeed support them or not.

Once thing is certain, for keyboard + gamepad to work you need to manually script OnKeyDown like you would in JS applications.
Since you have to have the specific widget which is focused listen for the same button press (or click, or controller trigger) that another similar widget would also listen to.

The process for that is obviously more complex, but still easily created as a default thing you can then re-use for every button throught your UI, making it simple.

1 Like