Global object for invoking native system dialogs. More...
Import Statement: | import Felgo 4.0 |
Inherits: |
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.
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!" } }) }
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 } }) } }
Displays a native alert dialog with a given title and description. It includes an OK button and an optional Cancel button that can also be localized.
The callback function will be called when one of the buttons is clicked. It receives a bool
value as the parameter, which is set to true
if the user chose to accept.
This method was introduced in Felgo 4.2.0.
|
Allows to take a photo by starting the native camera, if available. It copies the new photo to the app's private storage folder.
The callback function will be called when the created photo is submitted. 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 selected an image. The second parameter holds the path to the selected image or an empty string if canceled.
This method was introduced in Felgo 4.2.0.
Displays a modal alert sheet with the specific options. It uses an AlertDialog on Android and a UIActionSheet on iOS.
The native dialog shows the title and offers the specified items as options. The parameter cancelable decides whether the user can cancel the dialog or is forced to choose an option. The default behavior allows to cancel.
The callback function will be called when one of the items is clicked. It receives an int
value as the parameter, which holds the selected option or -1 if canceled.
This method was introduced in Felgo 4.2.0.
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.
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.
Allows to choose a date from a calendar by displaying a native date picker dialog, if available.
The parameters allow detailed control over the selectable dates. The initialDate
parameter specifies the date selected when the date picker is opened. The minDate
and the maxDate
parameters specify the range of selectable dates. It is also possible to omit all three parameters, or to only specify the initialDate
.
The callback function will be called when one of the buttons is clicked. It receives a bool
value as the first and a date
as the second parameter. The first parameter is set to
true
if the user pressed the OK button after selecting a date. The second parameter holds the year, month and day of month of the selected date.
This method was introduced in Felgo 4.2.0.
Displays a native file picker control. Different features are supported depending on the platform. The parameters are optional and match the QFileDialog::getOpenFileName capabilities:
The callback function will be called when one of the buttons is clicked on the file picker. It receives a bool
value as the first and a var
as the second parameter. The first parameter is
set to true
if the user selected one or more files. The second parameter holds a list of the file paths.
This method was introduced in Felgo 4.2.0.
|
Displays a native image picker control. Allows to choose a photo from the device by displaying the native image picker, if available. It copies the chosen photo to the app's private storage folder.
The callback function will be called when one of the buttons is clicked on the image picker. 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 selected an image. The second parameter holds the path to the selected image or an empty string if canceled.
This method was introduced in Felgo 4.2.0.