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

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.