Class Fullscreen
- All Implemented Interfaces:
Serializable
To enter fullscreen, bind a request to a user gesture via
onClick(Component) — the browser requires transient user activation
for each request, so the call only runs during the DOM event that fires the
underlying trigger:
Button fullscreenButton = new Button("Fullscreen");
Fullscreen.onClick(fullscreenButton).enter(); // whole page
Fullscreen.onClick(fullscreenButton).enter(videoPanel); // single component
To leave fullscreen, call exit(); to observe the current state,
subscribe to stateSignal(). Neither needs a user gesture.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexit()Exits fullscreen mode for the current UI if the page is currently in fullscreen; otherwise a no-op.static <T extends Component & ClickNotifier<?>>
FullscreenBindingonClick(T component) Registers the given component as a clickable trigger for a fullscreen request — the common shape for fullscreen buttons.static voidsetStateFromClient(UI ui, String value) Sets the fullscreen state of the given UI from a raw client-side value (e.g. from the initial bootstrap parameters).static Signal<FullscreenState> Returns a read-only signal that tracks the browser's fullscreen state for the current UI.
-
Method Details
-
onClick
Registers the given component as a clickable trigger for a fullscreen request — the common shape for fullscreen buttons. Equivalent tonew ClickTrigger(component), without making callers reach for the trigger framework's internal types.- Type Parameters:
T- the component type, must implementClickNotifier- Parameters:
component- the component to listen for clicks on, notnull- Returns:
- a new binding that can chain a fullscreen request to this trigger
-
stateSignal
Returns a read-only signal that tracks the browser's fullscreen state for the current UI.The signal distinguishes between
FULLSCREEN(the page is currently in fullscreen),NOT_FULLSCREEN(fullscreen is supported but the page is not in it),UNSUPPORTED(the browser does not support fullscreen or the document is not permitted to enter it), andUNKNOWN(the initial value, replaced with a real one before any user code observes the signal).The signal value is seeded from the initial client bootstrap, so user code always sees a real value. Subscribe with
Signal.effect(owner, ...)to react to changes; callstateSignal().peek()for a snapshot outside a reactive context, and.get()inside one.Example: toggle a CSS class while fullscreen
Example: react to state changes with a side effectviewLayout.bindClassName("is-fullscreen", Fullscreen.stateSignal().map(s -> s == FullscreenState.FULLSCREEN));Signal.effect(this, () -> { if (Fullscreen.stateSignal().get() == FullscreenState.UNSUPPORTED) { fullscreenButton.setVisible(false); } });- Returns:
- the read-only fullscreen signal for the current UI
- Throws:
IllegalStateException- if there is no current UI
-
exit
public static void exit()Exits fullscreen mode for the current UI if the page is currently in fullscreen; otherwise a no-op. The current state can be observed viastateSignal().If a component was previously fullscreened via
FullscreenBinding.enter(Component), it is automatically restored to its original position in the DOM.- Throws:
IllegalStateException- if there is no current UI
-
setStateFromClient
Sets the fullscreen state of the given UI from a raw client-side value (e.g. from the initial bootstrap parameters).nulland unknown values are ignored.Called from the bootstrap path in
ExtendedClientDetailsthat seeds the signal before any user code observes it. Not intended for application code.- Parameters:
ui- the UI whose fullscreen state to seed, notnullvalue- the raw value, ornull
-