Dialog Window Example

This example explains how to create a dialog window with "OK" and "Cancel" buttons, show on the screen and process the result.

See interactive example on http://www.redui.net

UI Model

{
    "windows": [
        {
            "name": "DialogWindowExample",
            "title": "Dialog Window Example",
            "left": 500,
            "top": 100,
            "width": 400,
            "height": 300,
            "controls": [
                {
                    "name": "infoStaticText",
                    "type": "statictext",
                    "text": "Confirm the action by clicking OK or Cancel"
                },
                {
                    "name": "OKButton",
                    "type": "button",
                    "text": "OK",
                    "isDialogButton": true,
                    "dialogResult": "OK"
                },
                {
                    "name": "CancelButton",
                    "type": "button",
                    "text": "Cancel",
                    "isDialogButton": true,
                    "dialogResult": "Cancel"
                }
            ]
        }
    ]
}

Code

var exampleWindow = redui.createNewWindow("DialogWindowExample");
exampleWindow.show();

exampleWindow.closed(function (target, dialogResult) {
	if (dialogResult === "OK") {
		alert("You clicked OK");
	}
	if (dialogResult === "Cancel") {
		alert("You clicked Cancel");
	}
});


.

Last edited Nov 20, 2013 at 11:19 AM by artemkv, version 2

Comments

No comments yet.