I’m trying to make an interaction where I would have several inventory slots and the way to interact with the slots would be: Hover the button and press a key (which will depend on which key for a certain action, for example: Hover + X to inspect, Hover + C to enter placement mode, etc.). Any ideas on how I can have this work?
inventory slots and the way to interact with the slots would be: Hover the button
Why are slots buttons?
Sounds like the typical approach should be enough:
onMouseEnter / Leave sets a isHovered flag and grants keyboard focus
onKeyDown invokes desired action; this could be a simple Switch, a cascading Branch or a tMap look-up
If you want something fancier:
have the slot dispatch hover state to the Player Controller
Enhanced Input → interface Message the widget → process slot → return some data to the PC
to enter placement mode
One way or another, consider dispatching UI processed data to the player controller and let it handle it. Avoid having slots look thing up in the world.
We’d need to see the script. If you need it looked at, ofc. I’ve been looking at script all day
That’d be one of the worst choices for a slot, imho. Avoid native buttons, I say. They’re… inflexible. Normally, you’d make a user widget slot, a simple border is pretty good. OnMouseEnter is your hover, all widgets support tooltips, and handling clicking is trivial by comparison. Native buttons are OK for simple clicks, but they should not do anything else. The way they hungrily consume input will give you a headache as soon as you try make them do anything unbuttonlike.
I made it work but I need a tip to make the mouse work too. After all, I’m using it onKeyDown and it doesn’t accept mouse keys. Do you have any idea how I could implement mouse keys in the graph with the already built cascade of branches?
Interesting . I’ll look into it further. I didn’t realize that buttons could consume input in this way, causing headaches in the future. Thanks for the tip!