Class FeedbackTray
A row of actions for rating and acting on a generated response.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class FeedbackTray : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, INotifyValueChanged<FeedbackValue>
Remarks
FeedbackTray pairs a thumbs up / thumbs down rating with two optional actions, regenerate and copy. It is the row you put under an assistant message.
The rating is a three-state value, see FeedbackValue. Pressing the active rating
clears it, so a user who mis-clicks can undo without a separate control. The active rating is
reported with the shared is-selected state class, the same one every other selectable
App UI control uses.
The two trailing actions are opt-in: canRefresh and canCopy reveal them, and they report their presses through refreshRequested and copyRequested. The tray does not copy anything itself — the host owns the clipboard — but it will reflect a completed copy by swapping the glyph to a checkmark while copied is set.
Examples
A tray under a chat message.
<ui:FeedbackTray can-copy="true" can-refresh="true" />
Wiring the tray up in C#.
var tray = new FeedbackTray { canCopy = true, canRefresh = true };
tray.RegisterValueChangedCallback(evt => SubmitRating(messageId, evt.newValue));
tray.refreshRequested += () => RegenerateResponse(messageId);
tray.copyRequested += () =>
{
GUIUtility.systemCopyBuffer = messageText;
tray.copied = true;
tray.schedule.Execute(() => tray.copied = false).ExecuteLater(2000);
};
Constructors
FeedbackTray()
Default constructor.
Declaration
public FeedbackTray()
Fields
buttonUssClassName
The styling class shared by every button of the tray.
Declaration
public const string buttonUssClassName = "appui-feedbacktray__button"
Field Value
| Type | Description |
|---|---|
| string |
copyUssClassName
The copy button styling class.
Declaration
public const string copyUssClassName = "appui-feedbacktray__copy"
Field Value
| Type | Description |
|---|---|
| string |
goodUssClassName
The "good" rating button styling class.
Declaration
public const string goodUssClassName = "appui-feedbacktray__good"
Field Value
| Type | Description |
|---|---|
| string |
poorUssClassName
The "poor" rating button styling class.
Declaration
public const string poorUssClassName = "appui-feedbacktray__poor"
Field Value
| Type | Description |
|---|---|
| string |
refreshUssClassName
The regenerate button styling class.
Declaration
public const string refreshUssClassName = "appui-feedbacktray__refresh"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The FeedbackTray main styling class.
Declaration
public const string ussClassName = "appui-feedbacktray"
Field Value
| Type | Description |
|---|---|
| string |
Properties
canCopy
Whether the copy button is available.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool canCopy { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
canRefresh
Whether the regenerate button is available.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool canRefresh { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
copied
Whether the copy button reports a completed copy. Swaps its glyph to a checkmark.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool copied { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
copyButton
The copy button. Hidden unless canCopy is set.
Declaration
public IconButton copyButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
goodButton
The thumbs up button.
Declaration
public IconButton goodButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
poorButton
The thumbs down button.
Declaration
public IconButton poorButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
refreshButton
The regenerate button. Hidden unless canRefresh is set.
Declaration
public IconButton refreshButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
value
The current rating. Defaults to None.
Declaration
[CreateProperty]
[UxmlAttribute]
public FeedbackValue value { get; set; }
Property Value
| Type | Description |
|---|---|
| FeedbackValue |
Methods
SetValueWithoutNotify(FeedbackValue)
Set the rating without raising a ChangeEvent_1.
Declaration
public void SetValueWithoutNotify(FeedbackValue newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| FeedbackValue | newValue | The new rating. |
Events
copyRequested
Raised when the copy button has been pressed. The host owns the clipboard.
Declaration
public event Action copyRequested
Event Type
| Type | Description |
|---|---|
| Action |
refreshRequested
Raised when the regenerate button has been pressed.
Declaration
public event Action refreshRequested
Event Type
| Type | Description |
|---|---|
| Action |