View
Related: GUI
View is comet's UI container abstraction. A view wraps either a dock widget or a viewport overlay and gives you a consistent API for mounting UI.
Visibility
Views start hidden by default. After mounting content, either call setVisible(true) yourself or link the view to a toggleable Button with linkButton().
mount()
Mounts UI into the view.
Type
mount<T extends GuiBase>(element: T, createCopy?: boolean): T;
mount(method: (root: Instance) => () => void): void;Notes
- The direct-instance overload reparents the
GuiBaseinto the view. - Set
createCopytotrueto clone the element before it is reparented. - The function overload is intended for React, Fusion, Vide, or any other UI runtime that returns an unmount callback.
Usage
view.mount((root) => {
const unmount = createReactTree(root);
return () => unmount();
});const frame = new Instance("Frame");
view.mount(frame);onClose()
Registers a callback that fires when a dock widget is closed by any source.
Type
onClose(cb: () => void): voidonOpen()
Registers a callback that fires when a dock widget is opened manually.
Type
onOpen(cb: () => void): voidisVisible()
Returns the view's visibility state.
Type
isVisible(): booleansetVisible()
Sets the view's enabled state.
Type
setVisible(state: boolean): voidlinkButton()
Synchronizes a toggleable toolbar button with the view's visibility.
WARNING
This throws if the button is not toggleable.
Type
linkButton(button: Button): voidWhen the view is closed, comet also clears the linked button's pressed state.
getViewportSize()
Returns container.AbsoluteSize.
Type
getViewportSize(): Vector2