FMX.Dialogs.InputQuery
Delphi
function InputQuery(const ACaption: string; const APrompts: array of string; var AValues: array of string;
const ACloseQueryFunc: TInputCloseQueryFunc): Boolean;
function InputQuery(const ACaption: string; const APrompts: array of string; var AValues: array of string;
const ACloseQueryEvent: TInputCloseQueryEvent; const AContext: TObject): Boolean;
function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
procedure InputQuery(const ACaption: string; const APrompts: array of string; const ADefaultValues: array of string;
const ACloseQueryProc: TInputCloseQueryProc);
procedure InputQuery(const ACaption: string; const APrompts: array of string; const ADefaultValues: array of string;
const ACloseQueryEvent: TInputCloseQueryWithResultEvent; const AContext: TObject);
procedure InputQuery(const ACaption, APrompt, ADefaultValue: string; const ACloseBoxProc: TInputCloseBoxProc);
procedure InputQuery(const ACaption, APrompt, ADefaultValue: string;
const ACloseQueryEvent: TInputCloseQueryWithResultEvent; const AContext: TObject); overload;
C++
extern DELPHI_PACKAGE bool __fastcall InputQuery _DEPRECATED_ATTRIBUTE1("Use FMX.DialogService methods") (const System::UnicodeString ACaption, const System::UnicodeString *APrompts, const System::NativeInt APrompts_High, System::UnicodeString *AValues, const System::NativeInt AValues_High, const _di_TInputCloseQueryFunc ACloseQueryFunc = _di_TInputCloseQueryFunc())/* overload */;
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
function | public | FMX.Dialogs.pas FMX.Dialogs.hpp |
FMX.Dialogs | FMX.Dialogs |
説明
警告: InputQuery は非推奨になっています。 Platform.IFMXDialogServiceAsync.MessageDialogAsync を使用してください。
複数の入力フィールドを持つダイアログ ボックスを表示します。
InputQuery を使用すると、APrompts
内の文字列と同じ数の TEdit コントロールを持つダイアログ ボックスを表示できます。
InputQuery は、次のパラメータを受け取ります:
ACaption
はダイアログ ボックスのタイトルを表します。APrompts
は、TEdit コントロールの左側に配置されるラベルを表します。ダイアログ内のフィールドをマスクされたフィールド(たとえば、パスワード フィールドなど)にするには、フィールド ラベルの前にフラグを付けます。AValues
またはADefaultValues
は TEdit コントロールのデフォルトのテキスト値です。ACloseQueryProc
は、ダイアログ ボックスが閉じるときに InputQuery により実行される無名メソッドです。
- メモ:
AValues
の長さはAPrompts
の長さ以上でなければなりません。
ユーザーが[OK]ボタンをクリックした場合、InputQuery は True
を返します。それ以外の場合は InputQuery は False
を返します。ACloseQueryProc
パラメータを指定した場合、InputQuery は値を返しません。ACloseQueryProc
メソッドに渡される AResult
引数で、ユーザーが何をクリックしたかがわかります。
ダイアログ ボックスの入力フィールドに入力された値は AValues
に格納されます。ACloseQueryProc
パラメータを指定した場合は、代わりに、InputQuery はそれらの入力値を ACloseQueryProc
メソッドに渡します。
InputQuery の呼び出しに ACloseQueryProc
パラメータが含まれていない場合、その呼び出しはすべてのプラットフォームでブロッキング呼び出しとなります。つまり、InputQuery は、ダイアログ ボックスが閉じるまでは制御を返しません。Android ではこれらのブロッキング呼び出しをサポートしていないので、Android で InputQuery を使用できるのは、ACloseQueryProc
パラメータを指定した場合だけです。
InputQuery をデスクトップ プラットフォームで呼び出した場合、ACloseQueryProc
パラメータが呼び出しに含まれているかいないかにかかわらず、その呼び出しは常にブロッキング呼び出しとなります。つまり、モバイル プラットフォームでは、InputQuery の呼び出し後のコードはすべて、ダイアログ ボックスが閉じる前に実行されます。ダイアログ ボックスが閉じた後でコードを実行する必要がある場合は、InputQuery の ACloseQueryProc
パラメータを使用して、そのコードを実行する無名メソッドを指定します。詳細については、以下を参照してください。
フィールドのマスク処理
以下は、2 つのフィールド([Username]フィールドとマスクされた[Password]フィールド)を持つ[Login]ダイアログ ボックスを表示するコード断片です。
Delphi の場合:
- Delphi では、フィールド ラベルの前に付いている "#1" が、マスクされたフィールドのフラグです。
InputQuery( 'Login', ['Username', #1'Password:'], ['', ''],
procedure(const AResult: TModalResult; const AValues: array of string)
begin
end);
- (お使いのユニットの .h ファイルで)TForm1 の定義の後に次の定義を追加します。
typedef void __fastcall(__closure * TInputCloseQueryProcEvent)
(const System::Uitypes::TModalResult AResult,
System::UnicodeString const *AValues, const int AValues_High);
- (お使いのユニットの .h ファイルで上記の型定義の後に)次のクラス定義を追加します。
class InputQueryMethod : public TCppInterfacedObject<TInputCloseQueryProc>
{
private:
TInputCloseQueryProcEvent Event;
public:
InputQueryMethod(TInputCloseQueryProcEvent _Event) {
Event = _Event;
}
void __fastcall Invoke(const System::Uitypes::TModalResult AResult,
System::UnicodeString const *AValues, const int AValues_High) {
Event(AResult, AValues, AValues_High);
}
};
- (お使いのユニットの .h ファイルで)フォームの private セクション下に次の宣言を追加します。
private: //User declarations
void __fastcall OnInputQuery_Close
(const System::Uitypes::TModalResult AResult,
System::UnicodeString const *AValues, const int AValues_High);
- (お使いのユニットの .cpp ファイルに)次のコードを追加します。
void __fastcall TForm1::OnInputQuery_Close(const System::Uitypes::TModalResult AResult,
System::UnicodeString const *AValues, const int AValues_High) {
}
- これで、次のコード断片を使用することができます。
- C++ では、フィールド ラベルの先頭の "\1" が、マスクされたフィールドのフラグです。
String caption = "Login";
String Prompts[2];
Prompts[0] = "Username";
Prompts[1] = "\1Password";
String Defaults[2];
Defaults[1] = "";
Defaults[0] = "";
_di_TInputCloseQueryProc Met = new InputQueryMethod(&OnInputQuery_Close);
InputQuery(caption, Prompts, sizeof(Prompts)/sizeof(Prompts[0]) - 1, Defaults, sizeof(Defaults)/sizeof(Defaults[0]) - 1, (TInputCloseQueryProc *)Met);
プラットフォーム サポート
InputQuery のどちらの呼び出しがどのプラットフォームでサポートされているか、および、それらの呼び出しがブロッキング呼び出しか非ブロッキング呼び出しかを次の表にまとめます。
プラットフォーム | ACloseQueryProc パラメータなし
|
ACloseQueryProc パラメータあり
|
---|---|---|
Windows | ブロッキング | ブロッキング |
OS X | ブロッキング | ブロッキング |
iOS | ブロッキング | 非ブロッキング |
Android | 非ブロッキング |