I’m making an interface for the first time. I have a WB_Inventory where a Cell (a Widget with only Border and Text) is added when an item is picked up. The WB_Inventory contains an Integer, which serves as the ID of focused Cell with the mouse. When I focus on the Widget, the Integer changes accordingly. When I click the mouse, an Implement Interface Event is sent to a specific ID.
But when I don’t focus on the Cell, the ID is retained, and I select the last focused item.
Is there a way to validate in the Interface what I’m clicking on? On empty space, or on a WB_Inventory component?
1.Place inventory cell widgets to any container like GridPanel/Canvas.
2.Set container visibility to Not Hit-Testable (Self Only)
3.Handle click event in cell widget. Widget should be Visible!
You can simply set interface function default value to -1 , so you can know -1 is unfocused variable.
OnClick/OnFocus you can extend your function to pass that on empty space or a better way not to run function at al. That comes with the wording mentioned above as visibility of the widgets as non hit testable resulting you maintaining focus.
If you dont want these and you want to engineer the function correctly better implement a OnInteractedEvent to buttons that runs the interface function correctly.
Hello everyone again! Thanks for the suggested methods!
I’m not using a Button to optimize the Interface, so Onclicked and other events aren’t suitable.
The Handle idea gives a better result, but I’m having a problem with focus sticking.
What I did:
Inside the widget, there’s a lightweight widget with two events: On Mouse Button Down, where Return Node = Handled. This causes focus sticking (the keys on the keyboard stop working until I click the mouse on an empty space).
I was hoping that using On Mouse Button UP, where Return Node = UnHandled, would fix the issue. But that didn’t work - focus stuck on the widget.