NativeDialog

Global object for invoking native system dialogs. More...

Import Statement: import VPlayApps 1.0
Inherits:

Item

Methods

  • confirm(string title, string description, function callback, bool allowCancel)
  • inputText(sring title, string description, string placeholder, string text, function callback)

Detailed Description

NativeDialog allows to invoke native system dialogs and may be used to confirm a user action or to request a text input from the user. NativeDialog is a global object, and can be used without creating additional QML objects.

As an alternative to invoking a native dialog, InputDialog may be used to show a QML based dialog. It also supports multi-line text input. If you want to show a dialog with custom content, use the Dialog component.

Confirm Dialog

The confirm dialog has a title and can display a message. The dialog can be canceled or accepted:

 AppButton {
   id: confirmBtn
   text: "Confirm Dialog"
   onClicked: NativeDialog.confirm("Please Confirm", "Confirm this action?", function(ok) {
     if(ok) {
       confirmBtn.text = "Confirmed!"
     }
   })
 }

Input Dialog

The input dialog allows to enter text and may either be cancelled or accepted:

 AppButton {
   id: inputBtn
   text: "Input Dialog"
   onClicked: {
     NativeDialog.inputText("Quick Question", "What do you think?", "Input here", "", function(ok, text) {
       if(ok) {
         inputBtn.text = "Input: " + text
       }
     })
   }
 }

Method Documentation

confirm(string title, string description, function callback, bool allowCancel)

Invokes the native confirm dialog with two buttons to cancel or accept. The optional allowCancel parameter is true by default and may be used to display a dialog with no cancel option.

The callback function will be called when one of the buttons is clicked. It receives a bool value as a parameter. It is set to true if the user chose to accept.


inputText(sring title, string description, string placeholder, string text, function callback)

Invokes a native input dialog that holds a text field and two buttons to cancel or accept. The text and placeholder parameter set the initial text of the input field and the placeholder text if it is empty.

The callback function will be called when one of the buttons is clicked. It receives a bool value as the first and a string as the second parameter. The first parameter is set to true if the user chose to accept. The second parameter holds the entered text.


Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support