Skip to main content Link Search Menu Expand Document (external link)

The Dialog Factory Interface

The dialog factory interface creates BrowserWindow instances meant to be used as dialogs in Jancy.

There is only one dialog factory and it can always be found at jancy.dialogFactory.

Methods

dialogFactory.create(parent, browserWindowOptions, options)

  • parent (BrowserWindow|string) the BrowserWindow that will be the parent of this dialog. When a string use ‘focused’ to get the currently focused tab
  • browserWindowOptions (object) options to override the defaults used by the factory
  • options (object) dialog factory specific options
    • centerRelativeToParent (boolean) optional if true the resulting dialog will be centerered relative to parent

Returns a BrowserWindow instance.

This example will open a dialog for the current tab and it will load google.com.

let dialog = jancy.dialogFactory.create(
  'focused',
  {
    width: 400,
    height: 175,
    title: 'My Dialog'
  },
  {
    centerRelativeToParent: true
  }
)
//example of loading a url in a dialog
dialog.once('ready-to-show', , () => {  
   dialog.webContents.loadURL("https://google.com")
   dialog.show() //needed to show the dialog
})

This example is to show how to use the error dialog in the dialog factory.

this.jancy.dialogFactory.errorDialog( ‘This is the title of the Dialog’, ‘This is the body of the Dialog.’ )