Dialog Boxes

This page introduces how to display dialogs such as message boxes.

Display a dialog with message and an OK button

Syntax
pd.alert(message, callback)
Parameters
Parameter Value Description
message String or DOM

A string you want to display in the dialog, or, alternatively, an HTML object that is converted into a string and displayed.

callback Function(Object)
[Optional]

The handler that will run when the button is clicked.

If there is any process you want to execute when the dialog is closed, describe it in this handler.

Response
None
Sample
((APP_ID) => {
	"use strict";
	const handler = (event) => {
		return new Promise((resolve,reject) => {
			pd.alert('Hello kumaneko!', () => {
				resolve(event);
			});
		});
	};
	pd.event.on(APP_ID, 'pd.view.load', handler);
})(pd.APP_ID);

Display a dialog with a message and two buttons, OK / Cancel

Syntax
pd.confirm(message, callback, cancelcapture)
Parameters
Parameter Value Description
message String or DOM

A string you want to display in the dialog, or, alternatively, an HTML object that is converted into a string and displayed.

callback Function(Object)
[Optional]

The handler that will run when the button is clicked.

If there is any process you want to execute when the dialog is closed, describe it in this handler.

cancelcapture Boolean
[Optional]

If you want to execute the handler specified in the callback parameter even when the cancel button is clicked, specify ture.

When cancelcapture is set to true and the cancel button is pressed, true is passed to the argument of the handler specified in the callback parameter.

Response
None
Sample
((APP_ID) => {
	"use strict";
	const handler = (event) => {
		return new Promise((resolve,reject) => {
			pd.confirm('Can I do it?', (cancel) => {
				if (cancel)
				{
					pd.alert('Let me do it next time!');
				}
				resolve(event);
			},true);
		});
	};
	pd.event.on(APP_ID, 'pd.view.load', handler);
})(pd.APP_ID);

Display a dialog prompting the user to input some text

Syntax
pd.input(message, callback, type, defaults)
Parameters
Parameter Value Description
message String or DOM

A string you want to display in the dialog, or, alternatively, an HTML object that is converted into a string and displayed.

callback Function(Object)

The handler that will run when the button is clicked.

Receives the string entered as an argument.

type Input format

If you need to hide the input value, specify "password", otherwise specify "text".

defaults String
[Optional]

Default value displayed in the text input field.

Response
None
Sample
((APP_ID) => {
	"use strict";
	pd.event.on(APP_ID, 'pd.change.field_1_', (event) => {
		const record = event.record;
		return new Promise((resolve,reject) => {
			if (record.field_1_.value=='')
			{
				pd.input('Please be sure to enter the name.', (value) => {
					record.field_1_.value=value;
					resolve(event);
				},'text');
			}
		});
	});
})(pd.APP_ID);