Skip to main content

dialog

The ui-dialog component allows developers to create windows.

Usage

import dialog from "../../sys/ui/components/dialog.js"
// dialog({your_dialog_opts})
var somedialog = await dialog({width: 300, height: 200, picto: "warning", label: "Test dialog", content: "Hello world!"})

Events

tip

Learn more about events in the events documentation

The following events are emitted by the dialog component:

  • ui:dialog.open
  • ui:dialog.close
  • ui:dialog.before-open
  • ui:dialog.before-remove
  • ui:dialog.activate
  • ui:dialog.maximize
  • ui:dialog.restore
  • ui:dialog.title-change
  • ui:dialog.picto-change
  • ui:dialog.pivot-change
  • ui:dialog.destroy

Dialog Options

PropertyTypeDescription
xIntThe x coordinate of where your dialog will pop up
yIntThe y coordinate of where your dialog will pop up
widthIntThe width of your dialog
heightIntThe height of your dialog
modalBooleanWhether to force the user to interact with the popup
stealFocusBooleanWhether the popup should automatically be focussed
clearBooleanWhether to render the window stuff
insetBooleanWhether to add inset (which is a kind of pushed in effect)
labelStringThe title of the popup
pictoStringThe icon of the dialog (in the top left)
footerStringThe footertext (does not get insetted)
contentString/plan/HTMLElementThe body of your dialog
resizableBooleanWhether your dialog is resizable
maximizableBooleanWhether your dialog can be maximized
minimizableBooleanWhether your dialog can be minimized (duh)
dockableBooleanWhether your dialog appears in the taskbar
workspaceWorkspaceIn which workspace it appears*
pivotStringFlexible way to specify in which area it pops up (see /42/ui/desktop/workspaces.js to see all available options)
pivotKindStringUnknown
geometryKindUnknownUnknown
* = Workspaces do not seem to be finished yet, for now just ignore this

Methods

close(bool ok)

Closes the dialog, ok doesn't really affect anything. The ok value won't be visible on the desktop.

resize(int width, int height, json options)

Resizes the dialog.

Available JSON options:

NameTypeDescription
widthIntThe width
heightIntThe height
centerBooleanMove dialog to center
animateBoolean/IntIf boolean, it specifies whether to animate the resize. If number, it specifies the duration of this animation
saveBooleanWhether to save the geometry (meaning size and position).
** = (speculation) I think this is so that if the dialog gets reopened it retains its position

moveToCenter(json options)

caution

This method seems to be buggy

Centers the dialog.

Available JSON options:

| Name | Type | Description | animate | Boolean | Whether to animate or not (seems to be broken) | fixOverlap | Boolean | Whether to call fixOverlap (whatever that means)