How can you make a knob also behave like a button?

Alright I know this sounds weird. But any of you who are familiar with tube guitar amplifiers know what I’m talking about. There are knobs which you can pull and it gives you a different flavour to the characteristic the knob contributes to.

So coming to the context of UE. How do I make a knob affect a different variable when it’s clicked on. Basically, users can cycle back and forth between these two modes. And maybe the knob becomes a little bigger to indicate that it is being ‘‘pulled’’.

I have no clue where to even begin so I decided to ask here to know if you guys have any ideas. Thanks!

The basic “button” widget on the UserWidget editor palette is OK for most situations since it already implements styleable modes for hover / press / default / disabled. I’d go with that widget and see if it’s easy to implement rotation by dragging / key press. I believe there is also a knob widget (is it the synthesis plugin?) but I’d not pick that if it misses the button’s visual feedback.

The button widget has a “OnPressed” delegate which executes when it is focused and you press the slate “accept” key which is enter or spacebar on a keyboard by default. that delegate also executes when you click a button so this is a great start. OnPressed you want to toggle a bool property between state A and B. I’d probably use 2 button widgets on top of one another. one button to visualize the pulled state, the other for the normal state. The UserWidget they live in would then hold the bool property. Something like (pseudocode):

UserWidget "MyButton" {
  bIsStateNormal = true;

  ButtonNormal (visible default);

  ButtonPulled (hidden default);
}

when MyButton->ButtonNormal->OnPressed:
- MyButton->bIsStateNormal = false;
- ButtonNormal->Hide();
- ButtonPulled->Show();

when MyButton->ButtonPulled->OnPressed:
- MyButton->bIsStateNormal = true;
- ButtonNormal->Show();
- ButtonPulled->Hide();

Then you only have to implement the knob rotation on the UserWidget “MyButton” and keep track of a rotation value.

  • Edit once you get that working, if you use a gamepad or similar HID remember to switch focus between ButtonNormal and ButtonPulled when you hide a button and show the other, otherwise they don’t receive key input.

Oh wow I will try this for sure thanks!