Friday, 18 July 2014

Application Development : System Dialogs, Prompts, and Toasts – SystemPrompt

SystemPrompt
You can use a SystemPromptto ask for some input from the user before continuing with your application flow. The SystemPrompt will display two default buttons for accepting or rejecting the dialog box and an input field for user input. You can retrieve the user’s input by calling SystemPrompt.inputFieldTextEntry() (see Listing 2).
Listing 2.  SystemPrompt
import bb.cascades 1.2
import bb.system 1.2
 
Page {
    Container {
        layout: DockLayout {
             
        }
        Button {
            text: "Show Dialog!"
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            onClicked: {
                myPrompt.show();
            }
        }
        attachedObjects: [
            SystemPrompt {
                title: "Enter a new file name"
                id: myPrompt
                onFinished: {
                    switch (value) {
                        case (SystemUiResult.ConfirmButtonSelection):
                            console.log("new file name is: "+myPrompt.inputFieldTextEntry())
                            break;
                        case (SystemUiResult.CancelButtonSelection):
                            console.log("new file canceled");
                            break;
                        default:
                            break;
                    }
                }
            }
        ]
 
    }
}
Figure  shows the SystemPrompt when displayed.
Figure . SystemPrompt

No comments:

Post a Comment