Unit CastleDialogViews
Description
Dialog windows (to display some information, or ask user for confirmation, or ask user to input a simple value) as a user-interface view (TCastleView). This unit defines the user-interface view classes (TCastleView descendants) to display given dialog.
If you use TCastleWindow with most platforms (but not iOS), then it's usually more comfortable to use the unit CastleMessages instead of this unit. Using the CastleMessages, you get comfortable functions like MessageOK and MessageYesNo that wait until user presses a button (like "OK", "Yes", "No") to close the dialog. This is comfortable to use, as you can write code like this:
if MessageYesNo(Window, 'Are you sure you want to delete this file?') then DeleteFile(...);
Underneath, the MessageYesNo will use a TViewDialogYesNo, making sure that your normal window callbacks are redirected as appropriate. But you don't need to be concerned with this.
However, if you need to work on iOS, then you cannot use most of routines from the CastleMessages unit. You can use MessageOK if you turn on the MessageOKPushesView flag, but nothing else. E.g. MessageYesNo cannot work on iOS now. Making modal boxes like that is not supported on iOS.
In this case you should use this unit and instantiate the user-interface classes yourself, and you need to organize your whole game using TCastleView classes. See https://castle-engine.io/views about how to use TCastleView. Like this:
type TMyGameView = class(TCastleView) private DialogAskDeleteFile: TViewDialogYesNo; public function Press(const Event: TInputPressRelease): boolean; override; procedure Resume; override; end; function TMyGameView.Press(const Event: TInputPressRelease): boolean; override; begin Result := inherited; if Result then Exit; if Event.IsKey(keyEnter) then begin DialogAskDeleteFile := TViewDialogYesNo.Create(Self); DialogAskDeleteFile.Caption := 'Are you sure you want to delete this file?'; Container.PushView(DialogAskDeleteFile); end; end; procedure TMyGameView.Resume; begin inherited; if DialogAskDeleteFile <> nil then // returning from DialogAskDeleteFile begin if DialogAskDeleteFile.Answer then DeleteFile(...); FreeAndNil(DialogAskDeleteFile); end; end;
Uses
- Classes
- Math
- CastleGLUtils
- CastleUtils
- CastleImages
- CastleStringUtils
- CastleVectors
- CastleKeysMouse
- CastleControls
- CastleRectangles
- CastleColors
- CastleUIControls
- CastleFonts
- CastleInternalRichText
- CastleTimeUtils
Overview
Classes, Interfaces, Objects and Records
Name | Description |
---|---|
Class TViewDialog |
Abstract class for a modal dialog user-interface view. |
Class TViewDialogOK |
Wait for simple confirmation ("OK") from user. |
Class TViewDialogYesNo |
Ask user a simple "yes" / "no" question. |
Class TViewDialogChoice |
Ask user to choose from a number of options. |
Class TViewDialogInput |
Ask user to input a string, or cancel. |
Class TViewDialogKey |
Ask user a press any key, and return this key. |
Class TViewDialogPressEvent |
Ask user a press anything (key, mouse button, mouse wheel), for example to configure a keybinding for a game. |
Generated by PasDoc 0.16.0-snapshot.