LoginSignup
0
0

More than 1 year has passed since last update.

JXA(JavaScript で書いた AppleScript)で window.prompt(); を使いたい

Posted at
/**
 * JavaScript の window.prompt() のようなものを実行する。
 * @param {string} msg 表示したいメッセージ。'\n' で改行できます。
 * @param {string} answerDefault 規定の答え(オプション)。
 * @param {string} icon アイコン(("stop" | "note" | "caution")。規定は "note")。
 * @param {array} buttons 設置するボタン名の配列(既定は "OK" ひとつ)。
 * @param {string} defaultBtn デフォルトにしたいボタン名(既定は "OK")。
 * @returns 返り値オブジェクト。例:{buttonReturned:OK, textReturned:foobar}
 */
function prompt(msg,
    answerDefault = "",
    icon = "note",
    buttons = ["OK"],
    defaultBtn = "OK") {

    var app = Application.currentApplication();
    app.includeStandardAdditions = true;

    return app.displayDialog(msg, {
        defaultAnswer: answerDefault,
        withIcon: icon,
        buttons: buttons,
        defaultButton: defaultBtn,
    });
}

prompt("お名前を入力してください。", "your name");
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0