Class TViewDialogInput

Unit

Declaration

type TViewDialogInput = class(TViewDialog)

Description

Ask user to input a string, or cancel. See unit CastleDialogViews documentation for example usage.

Hierarchy

Overview

Methods

Protected procedure InitializeButtons(var Buttons: TViewDialog.TButtonArray); override;
Protected function DrawInputText: boolean; override;
Public function Press(const Event: TInputPressRelease): boolean; override;

Properties

Public property AllowedChars: TSetOfChars read FAllowedChars write FAllowedChars;
Public property MinLength: Cardinal read FMinLength write FMinLength default 0;
Public property MaxLength: Cardinal read FMaxLength write FMaxLength default 0;
Public property CanCancel: boolean read FCanCancel write FCanCancel default false;
Public property AnswerCancelled: boolean read FAnswerCancelled;
Public property Answer: String read GetAnswer write SetAnswer;

Description

Methods

Protected procedure InitializeButtons(var Buttons: TViewDialog.TButtonArray); override;

This item has no description.

Protected function DrawInputText: boolean; override;

This item has no description.

Public function Press(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Press.

Override this method to react to user pressing a key, mouse button or mouse wheel. Return True if the event was handled, which prevents from passing this event to other UI controls.

When implementing in descendants it is best to override it like this:

function TMyControl.Press(const Event: TInputPressRelease): boolean;
begin
  Result := inherited;
  if Result then Exit; // exit if ancestor already handled this event

  if Event.IsKey(keyEnter) then
  begin
    // do something in reaction to Enter key
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;

  if Event.IsMouseButton(buttonLeft) then
  begin
    // do something in reaction to left mouse button press
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;
end;

These events are generated for all UI controls, whether they are considered "interactive" or not. These events are generated for non-interactive controls like TCastleRectangleControl or TCastleLabel as well. For example, these events ignore the TCastleButton.Enabled state, they are generated always (see https://github.com/castle-engine/castle-engine/issues/413 ). Use instead TCastleButton.OnClick to detect clicks on a button in a way that honors the TCastleButton.Enabled state.

When a control returns True from Press, it means it starts to "capture" subsequent mouse events: subsequent mouse moves and release will be send to this control even if mouse will move outside of this control.

The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.Render, which is the standard place you should draw stuff. For example our TCastleButton draws there.

In contrast, the events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. In partcular, overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.RenderOverChildren.

Properties

Public property AllowedChars: TSetOfChars read FAllowedChars write FAllowedChars;

Allowed characters that user can input.

Public property MinLength: Cardinal read FMinLength write FMinLength default 0;

Min length of user input.

Public property MaxLength: Cardinal read FMaxLength write FMaxLength default 0;

Max length of user input. Value of 0 (default) means "no limit".

Public property CanCancel: boolean read FCanCancel write FCanCancel default false;

User can cancel the input by pressing a button like "cancel".

Public property AnswerCancelled: boolean read FAnswerCancelled;

User clicked "cancel" instead of accepting an answer. This is defined only when Answered. This is possible only if CanCancel.

Public property Answer: String read GetAnswer write SetAnswer;

The user input. May be set before starting the view. After the view stopped, if Answered, then this contains user answer. You should ignore it if AnswerCancelled.


Generated by PasDoc 0.16.0-snapshot.