Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

NativeDialog

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

Import Statement: import Felgo 4.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.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded