Right mouse clickable button

How to make a right mouse clickable button???

I tried with custom C++ UButton/SButton inheriting class but seems like a pain in the as*. I’ve replaced my Blueprint UButton with a checkbox + OnMouseButton event handler overriden with proper blueprint flow, but seems like calling SetCheckedState does not update the visual. I’ve ended up with a piece of blueprint that calls some custom events but I’m still unable to reflect the UI componet visual correctly (pressed state). It’s stunning that version 5 of the engine capable of insane 3D graphics lacks such a feature!

What is the aim? I’m trying to rewrite classic Fallout 2 with UE5 and I’ve came to a moment I need to switch between aimed/non-aimed attacks which involves right-mouse-button clicking the same UI element used to actually attack. Please help!

Not sure what exactly you trying to do but depends. As far as I understood you don’t have to inherit SButton/UButton for that actually.

OnWidget->OverrideFunction->MouseButtonDown and resolve over the function if button action is your action which is RMB.


Resolve its Event with a condition.

Something like this or you can query enhanced input subsystem for action which would be better.

Furthermore if there is an action already triggering a system, (in your case AimedAttack), after that this is just a state or event. You can make a GetAttackState() from somewhere or OnAttackStateChanged to drive the UI side. Since in my opinion If this is not UI driven but input driven system, UI can be just a listener.

I have that already - below is my OnMouseButtonDown overriden method’s blueprint:

And it in general works by means the RMB is handled correctly. The only thing that seems to have issues is handling the Checkbox state visual state - calling SetIsChecked does not update the actual visual state - the Checkbox stays unclicked even if it’s state in the Widget Reflector is Checked. It seems like I would need to ‘release’ control of the flow of the logic and asynchronously change it’s state so the UI update the Checkbox images to Checked (which is the same as Unchecked Pressed image).

Hi, OnMouseButtonDown should fire only once when RMB is pressed. Releasing RMB is handled separately by OnMouseButtonUp.

If your Input Action uses a Press and Release trigger, the action itself normally triggers once after the button is released, but that should not cause OnMouseButtonDown to fire again.

So, if Widget Reflector shows the Checkbox as checked, there seems to be a visual-state problem rather than a logic problem. I would also check the hovered states, because those brushes can cause the Checkbox to be logically checked while still displaying the wrong hovered visual.

You can also try running a script that unchecks the other Checkboxes before setting the selected one to checked, assuming only one of them should remain active.

OK - got it finally sorted. I used the most primitive, dumbest solution ever - UImage with brushe’s image changed on widget’s OnMouseDown/OnMouseUp events respectively. Works like a charm, but I expected more from UT TBH :smiley: