CommonUI plugin: how to display a bound action inline using CommonRichTextBlock

Same as the title, is it possible to somehow use the commonUI input action datatable as a decorator class? or is there some other technique.

It’s possible and something that CommonUI should support by default. I created a ticket for it here: Unreal Engine Issues and Bug Tracker (UE-185017)

In the meantime. What you can do is as you described use decorators to do this. Specifically:

  1. Use a ‘FWidgetDecorator’ and bind ‘FWidgetDecorator::Create’ to a ‘FWidgetDecorator::FCreateWidget::CreateUObject’ callback on your class.
  2. In your callback say ‘UMyRichTextBlock::OnCreateBoundActionWidget’…
  3. Create a new instance of a custom UWidget designed to display your widget, a good starting place here might be using CommonActionWidget.
  4. Use payload the FTextRunInfo from the rich text block to get the desired the action
  5. If using enhanced input, the name of the action itself should be sufficient, use the player controller / IEnhancedInputSubsystemInterface to get the input action from the text
  6. If using plain CommonUI datatables, then you could either make the entire datatable row a property on the rich text subclass so CommonUI icon info can be looked up via methods like ‘CommonUI::GetInputActionData’, or you can make the datatable a reference and allow the text to specify row lookup within that datatable.
  7. Either way by setting the relevant action info on your custom Widget / Custom Widget’s CommonActionWidget, you should be able to construct a widget that previews the relevant action, then return that widget via ‘FSlateWidgetRun::FWidgetRunInfo’ to view in your rich text.
1 Like