PromptParams
Parameters for the prompt dialog.
import { PromptParams } from '@mobrowser/api';
Example
import { app, PromptParams } from '@mobrowser/api';
const win = app.createWindow()
win.browser.handle('prompt', async (params: PromptParams) => {
const result = await app.showMessageDialog({
parentWindow: win,
title: params.title,
message: params.message,
textFields: [{
placeholder: params.defaultValue,
value: params.defaultValue
}],
buttons: [
{ label: params.labelCancel, type: 'secondary' },
{ label: params.labelOk, type: 'primary' }
]
})
if (
result.button.type === 'primary' &&
result.textFieldValues?.[0] !== undefined
) {
return { action: 'ok' as const, value: result.textFieldValues[0] }
}
return 'cancel'
})
Properties
url
readonly url: string;
The URL of the page that requested the dialog.
title
readonly title: string;
The localized dialog title.
message
readonly message: string;
The message passed to the window.prompt() JavaScript function.
defaultValue
readonly defaultValue: string;
The default value passed to the window.prompt() JavaScript function.
labelOk
readonly labelOk: string;
The localized label for the “OK” button.
labelCancel
readonly labelCancel: string;
The localized label for the “Cancel” button.