Stay organized with collections
Save and categorize content based on your preferences.
blockly > dialog
dialog namespace
Functions
Function |
Description |
alert(message, opt_callback) |
Wrapper to window.alert() that app developers may override via setAlert to provide alternatives to the modal browser window. |
confirm(message, callback) |
Wrapper to window.confirm() that app developers may override via setConfirm to provide alternatives to the modal browser window. |
prompt(message, defaultValue, callback) |
Wrapper to window.prompt() that app developers may override via setPrompt to provide alternatives to the modal browser window. Built-in browser prompts are often used for better text input experience on mobile device. We strongly recommend testing mobile when overriding this. |
setAlert(alertFunction) |
Sets the function to be run when Blockly.dialog.alert() is called. |
setConfirm(confirmFunction) |
Sets the function to be run when Blockly.dialog.confirm() is called. |
setPrompt(promptFunction) |
Sets the function to be run when Blockly.dialog.prompt() is called. **Important**: When overridding this, be aware that non-native prompt experiences may require managing ephemeral focus in FocusManager. This isn't needed for the native window prompt because it prevents focus from being changed while open. |
setToast(toastFunction) |
Sets the function to be run when Blockly.dialog.toast() is called. |
toast(workspace, options) |
Displays a temporary notification atop the workspace. Blockly provides a default toast implementation, but developers may provide their own via setToast. For simple appearance customization, CSS should be sufficient. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eBlockly.dialog\u003c/code\u003e namespace provides wrapper functions for \u003ccode\u003ealert\u003c/code\u003e, \u003ccode\u003econfirm\u003c/code\u003e, and \u003ccode\u003eprompt\u003c/code\u003e, offering alternatives to the standard browser dialogs.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can customize the behavior of these dialogs by setting their own functions using \u003ccode\u003esetAlert\u003c/code\u003e, \u003ccode\u003esetConfirm\u003c/code\u003e, and \u003ccode\u003esetPrompt\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBlockly.dialog\u003c/code\u003e is primarily designed to improve user experience, especially on mobile devices where browser prompts may not be ideal for text input.\u003c/p\u003e\n"],["\u003cp\u003eIt's highly recommended to thoroughly test on mobile devices when overriding the default prompt functionality to ensure optimal user experience.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [dialog](./blockly.dialog_namespace.md)\n\ndialog namespace\n----------------\n\nFunctions\n---------\n\n| Function | Description |\n|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [alert(message, opt_callback)](./blockly.dialog_namespace.alert_1_function.md) | Wrapper to window.alert() that app developers may override via setAlert to provide alternatives to the modal browser window. |\n| [confirm(message, callback)](./blockly.dialog_namespace.confirm_1_function.md) | Wrapper to window.confirm() that app developers may override via setConfirm to provide alternatives to the modal browser window. |\n| [prompt(message, defaultValue, callback)](./blockly.dialog_namespace.prompt_1_function.md) | Wrapper to window.prompt() that app developers may override via setPrompt to provide alternatives to the modal browser window. Built-in browser prompts are often used for better text input experience on mobile device. We strongly recommend testing mobile when overriding this. |\n| [setAlert(alertFunction)](./blockly.dialog_namespace.setalert_1_function.md) | Sets the function to be run when Blockly.dialog.alert() is called. |\n| [setConfirm(confirmFunction)](./blockly.dialog_namespace.setconfirm_1_function.md) | Sets the function to be run when Blockly.dialog.confirm() is called. |\n| [setPrompt(promptFunction)](./blockly.dialog_namespace.setprompt_1_function.md) | Sets the function to be run when Blockly.dialog.prompt() is called. \\*\\*Important\\*\\*: When overridding this, be aware that non-native prompt experiences may require managing ephemeral focus in FocusManager. This isn't needed for the native window prompt because it prevents focus from being changed while open. |\n| [setToast(toastFunction)](./blockly.dialog_namespace.settoast_1_function.md) | Sets the function to be run when Blockly.dialog.toast() is called. |\n| [toast(workspace, options)](./blockly.dialog_namespace.toast_1_function.md) | Displays a temporary notification atop the workspace. Blockly provides a default toast implementation, but developers may provide their own via setToast. For simple appearance customization, CSS should be sufficient. |"]]