Class ZoomTriggerButton
The control that opens an image full-size.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class ZoomTriggerButton : IconButton, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, ISizeableElement, IPressable
Remarks
Shared so that every surface offering this affordance looks and reads the same, and so the accessible-name wording lives in exactly one place: assetName names the thing being enlarged, and the component turns it into the tooltip View larger preview of <name>.
It stops propagation. The control usually sits on top of something whose own click, or Enter/Space activation, means select me, and enlarging is not selecting. The pointer-down is stopped too: a host that selects on pointer down, to arm a drag gesture say, would otherwise select the thing underneath before the click even fires. Stopping it does not affect the button's own activation, because clickable is a manipulator on this element and runs before the event reaches an ancestor.
It hides until it is wanted. The button rests at zero opacity so a dense grid of thumbnails
stays calm, and reveals on its own :focus or when the host raises revealed — which
is what ZoomableThumbnail does on hover. USS has no :focus-within and no
group-hover, so the host owning the hover is the UI Toolkit shape of the registry's
group-hover/zoom:opacity-100.
On a platform with no hover at all, alwaysVisible defaults to true and the control simply stays on screen. A zero-opacity element is still hit-testable, so hiding it on a touch device would not spare the user the control — it would only make it invisible, and a tap near the corner of a tile would open a viewer with nothing on screen to explain why.
Examples
A standalone zoom control.
var zoom = new ZoomTriggerButton { assetName = "Cliff face, tiling" };
zoom.clicked += () => lightbox.Show(rootVisualElement);
UXML declaration.
<appui:ZoomTriggerButton asset-name="Cliff face, tiling" />
Constructors
ZoomTriggerButton()
Default constructor.
Declaration
public ZoomTriggerButton()
ZoomTriggerButton(string, Action)
Construct a ZoomTriggerButton naming the asset it enlarges.
Declaration
public ZoomTriggerButton(string assetName, Action clickEvent = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assetName | Names the thing being enlarged; becomes the accessible label. |
| Action | clickEvent | Invoked when the control is activated. |
Fields
accessibleNameFormat
The tooltip wording, with the asset name substituted in.
Declaration
public const string accessibleNameFormat = "View larger preview of {0}"
Field Value
| Type | Description |
|---|---|
| string |
alwaysVisibleUssClassName
The styling class carried while the control never hides.
Declaration
public const string alwaysVisibleUssClassName = "appui-zoomtriggerbutton--always-visible"
Field Value
| Type | Description |
|---|---|
| string |
revealedUssClassName
The styling class carried while the control is revealed by its host.
Declaration
public const string revealedUssClassName = "appui-zoomtriggerbutton--revealed"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The ZoomTriggerButton main styling class.
Declaration
public const string ussClassName = "appui-zoomtriggerbutton"
Field Value
| Type | Description |
|---|---|
| string |
zoomIconName
The icon this control always shows.
Declaration
public const string zoomIconName = "magnifying-glass"
Field Value
| Type | Description |
|---|---|
| string |
Properties
alwaysVisible
Whether the control stays visible instead of hiding until hover or focus.
Declaration
[CreateProperty]
[UxmlAttribute("always-visible")]
public bool alwaysVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Defaults to true on a platform with no hover, for the reason spelled out on the type.
assetName
Names the thing being enlarged. Becomes the accessible label.
Declaration
[CreateProperty]
[UxmlAttribute("asset-name")]
[Header("Zoom Trigger Button")]
public string assetName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
revealed
Whether the host is currently revealing the control.
Declaration
[CreateProperty]
[UxmlAttribute("revealed")]
public bool revealed { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
USS has no :focus-within and no group-hover, so a host that reveals this control on its
own hover raises this flag instead. The control's own :focus reveals it without any help.