Class AnchorPopup<T>
Base class for Popup that can be anchored to another UI Element.
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public abstract class AnchorPopup<T> : Popup<T> where T : AnchorPopup<T>
Type Parameters
| Name | Description |
|---|---|
| T | The sealed anchor popup class type. |
Constructors
AnchorPopup(VisualElement, VisualElement, VisualElement)
Default constructor.
Declaration
protected AnchorPopup(VisualElement referenceView, VisualElement view, VisualElement contentView = null)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | referenceView | The visual element used as context provider for the popup. |
| VisualElement | view | The popup visual element itself. |
| VisualElement | contentView | The content that will appear inside this popup. |
Fields
m_OnAnchorGeometryChangedAction
Callback for Event triggered when the anchor geometry has changed.
Declaration
protected readonly EventCallback<GeometryChangedEvent> m_OnAnchorGeometryChangedAction
Field Value
| Type | Description |
|---|---|
| EventCallback<GeometryChangedEvent> |
m_OnAnimatedInAction
Callback for Event triggered when the popup has been shown.
Declaration
protected readonly EventCallback<ITransitionEvent> m_OnAnimatedInAction
Field Value
| Type | Description |
|---|---|
| EventCallback<ITransitionEvent> |
m_OnContentGeometryChangedAction
Callback for Event triggered when the content geometry has changed.
Declaration
protected readonly EventCallback<GeometryChangedEvent> m_OnContentGeometryChangedAction
Field Value
| Type | Description |
|---|---|
| EventCallback<GeometryChangedEvent> |
Properties
anchor
The popup's anchor.
Declaration
public VisualElement anchor { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
arrowVisible
True if the small arrow used next to the anchor should be visible, False otherwise.
Declaration
public bool arrowVisible { get; }
Property Value
| Type | Description |
|---|---|
| bool |
containerPadding
The padding in pixels, inside the popup panel's container.
Declaration
public int containerPadding { get; }
Property Value
| Type | Description |
|---|---|
| int |
crossOffset
The offset in pixels, in the direction of the secondary placement vector.
Declaration
public int crossOffset { get; }
Property Value
| Type | Description |
|---|---|
| int |
currentPlacement
The current placement.
Declaration
public PopoverPlacement currentPlacement { get; }
Property Value
| Type | Description |
|---|---|
| PopoverPlacement |
Remarks
The current placement can be different from the placement set with SetPlacement(PopoverPlacement), based on the current position of the anchor on the screen and the ability to flip placement.
offset
The offset in pixels, in the direction of the primary placement vector.
Declaration
public int offset { get; }
Property Value
| Type | Description |
|---|---|
| int |
outsideClickDismissEnabled
True if the popup can be dismissed by clicking outside of it, False otherwise.
Declaration
public bool outsideClickDismissEnabled { get; protected set; }
Property Value
| Type | Description |
|---|---|
| bool |
outsideClickStrategy
The strategy used to determine if the click is outside the popup.
Declaration
public OutsideClickStrategy outsideClickStrategy { get; protected set; }
Property Value
| Type | Description |
|---|---|
| OutsideClickStrategy |
outsideScrollEnabled
True if the popup let the user scroll outside of it, False otherwise.
Declaration
public bool outsideScrollEnabled { get; protected set; }
Property Value
| Type | Description |
|---|---|
| bool |
placement
The desired placement.
Declaration
public PopoverPlacement placement { get; }
Property Value
| Type | Description |
|---|---|
| PopoverPlacement |
Remarks
You can set the desired placement using SetPlacement(PopoverPlacement).
shouldFlip
True if the popup will be displayed at the opposite position if there's not enough
place using the preferred placement, False otherwise.
Declaration
public bool shouldFlip { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
AnimateViewIn()
Start the animation for this popup.
Declaration
protected override void AnimateViewIn()
Overrides
AnimateViewOut(DismissType)
Start the hide animation for this popup.
Declaration
protected override void AnimateViewOut(DismissType reason)
Parameters
| Type | Name | Description |
|---|---|---|
| DismissType | reason | The reason for the dismissal. |
Overrides
GetMovableElement()
Method which must return the visual element that needs to be moved, based on the anchor position and size.
Declaration
public virtual VisualElement GetMovableElement()
Returns
| Type | Description |
|---|---|
| VisualElement | The visual element which will be moved. The default value is view. |
HideView(DismissType)
Called when the popup's Handler has received a k_PopupDismiss message.
Declaration
protected override void HideView(DismissType reason)
Parameters
| Type | Name | Description |
|---|---|---|
| DismissType | reason | The reason why the popup should be dismissed. |
Overrides
InvokeDismissedEventHandlers(DismissType)
Called when the popup has been dismissed. This method will invoke any handlers attached to the dismissed event.
Declaration
protected override void InvokeDismissedEventHandlers(DismissType reason)
Parameters
| Type | Name | Description |
|---|---|---|
| DismissType | reason | The reason for the dismissal. |
Overrides
InvokeShownEventHandlers()
Called when the popup has become visible. This method will invoke any handlers attached to the shown event.
Declaration
protected override void InvokeShownEventHandlers()
Overrides
OnAnimatedIn(ITransitionEvent)
Called when the popup has been animated in.
Declaration
protected virtual void OnAnimatedIn(ITransitionEvent evt)
Parameters
| Type | Name | Description |
|---|---|---|
| ITransitionEvent | evt | The transition event. |
OnLayoutReadyToAnimateIn()
Called when the layout is ready to be animated in.
Declaration
protected override void OnLayoutReadyToAnimateIn()
Overrides
PrepareAnimateViewIn()
Called a frame before AnimateViewIn() to prepare the layout a final time.
Declaration
protected override void PrepareAnimateViewIn()
Overrides
RefreshPosition()
Recompute the position of the popup based on the anchor's position and size, but also others properties such as the offset, crossOffset, shouldFlip and placement.
Declaration
protected void RefreshPosition()
SetAnchor(VisualElement)
Set a new value for the anchor property.
Declaration
public T SetAnchor(VisualElement value)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | value | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
Remarks
This will trigger a refresh of the current popup position automatically.
SetArrowVisible(bool)
Set a new value for the arrowVisible property.
Declaration
public T SetArrowVisible(bool visible)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | visible | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
Remarks
This will trigger a refresh of the current popup position automatically.
SetContainerPadding(int)
Set a new value for the containerPadding property.
Declaration
public T SetContainerPadding(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
Remarks
This will trigger a refresh of the current popup position automatically.
SetCrossOffset(int)
Set a new value for the crossOffset property.
Declaration
public T SetCrossOffset(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
SetOffset(int)
Set a new value for the offset property.
Declaration
public T SetOffset(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
SetOutsideClickDismiss(bool)
Activate the possibility to dismiss the popup by clicking outside of it.
Declaration
public T SetOutsideClickDismiss(bool dismissEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | dismissEnabled |
|
Returns
| Type | Description |
|---|---|
| T | The popup of type |
SetOutsideClickStrategy(OutsideClickStrategy)
Set the strategy used to determine if the click is outside of the popup.
Declaration
public T SetOutsideClickStrategy(OutsideClickStrategy strategy)
Parameters
| Type | Name | Description |
|---|---|---|
| OutsideClickStrategy | strategy | The strategy to use. |
Returns
| Type | Description |
|---|---|
| T | The popup of type |
SetOutsideScrollEnabled(bool)
Activate the possibility to scroll outside of the popup.
Declaration
public T SetOutsideScrollEnabled(bool scrollEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | scrollEnabled |
|
Returns
| Type | Description |
|---|---|
| T | The popup of type |
SetPlacement(PopoverPlacement)
Set the preferred placement value.
Declaration
public T SetPlacement(PopoverPlacement popoverPlacement)
Parameters
| Type | Name | Description |
|---|---|---|
| PopoverPlacement | popoverPlacement | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
Remarks
This will trigger a refresh of the current popup position automatically.
SetShouldFlip(bool)
Set a new value for the shouldFlip property.
Declaration
public T SetShouldFlip(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new value. |
Returns
| Type | Description |
|---|---|
| T | The popup. |
Remarks
This will trigger a refresh of the current popup position automatically.
ShouldDismiss(DismissType)
Returns True if the popup should be dismissed, False otherwise.
Declaration
protected override bool ShouldDismiss(DismissType reason)
Parameters
| Type | Name | Description |
|---|---|---|
| DismissType | reason | The reason for the dismissal. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
ShouldRefreshPosition()
Method to determine if the position of the popup should be refreshed every time the anchor or the popup's content geometry changes.
Declaration
protected virtual bool ShouldRefreshPosition()
Returns
| Type | Description |
|---|---|
| bool |
|