Download Now

    Reference TEdit

    Declared in Codebot.Render.Widgets.pas on line 506

    TEdit is a single line text box. Text can be typed, selected with the mouse or with shift and the arrow keys, and copied, cut, and pasted. Control with the arrow keys moves by words, Home and End move to the ends, and Control+A selects everything. The text scrolls to keep the caret in view, and the caret blinks while the edit has focus.
    Positions are byte offsets into the UTF-8 text, always at the start of a character. Themes draw the text EditPadding pixels inside the bounds.
      TEdit = class(TWidget)
      protected
        function AutoSize: Boolean; override;
        function CanSelect: Boolean; override;
        procedure DoKeyDown(var Args: TSceneKeyArgs); override;
        procedure DoKeyUp(var Args: TSceneKeyArgs); override;
        procedure DoTextInput(var Args: TSceneTextArgs); override;
        procedure DoMouseDown(var Args: TSceneMouseArgs); override;
        procedure DoMouseMove(var Args: TSceneMouseArgs); override;
      public
        { Select all of the text }
        procedure SelectAll;
        { Copy the selected text to the clipboard }
        procedure CopyToClipboard;
        { Copy the selected text to the clipboard and remove it }
        procedure CutToClipboard;
        { Replace the selected text with the text on the clipboard }
        procedure PasteFromClipboard;
        { Themes call ScrollToCaret before drawing with the width available for text }
        procedure ScrollToCaret(TextWidth: Float);
        { Returns the width of the text before a position }
        function OffsetOf(Position: Integer): Float;
        { Returns True when the caret should be drawn in the current blink }
        function CaretVisible: Boolean;
        { The position of the caret }
        property Caret: Integer read FCaret;
        { The position where the selection begins }
        property SelStart: Integer read GetSelStart;
        { The number of bytes selected }
        property SelLength: Integer read GetSelLength;
        { The selected text }
        property SelText: string read GetSelText;
        { The number of pixels the text is scrolled to the left }
        property Scroll: Float read FScroll;
        property Text;
        property OnChange;
        property OnClick;
        property OnKeyDown;
        property OnKeyUp;
        property OnMouseDown;
        property OnMouseMove;
        property OnMouseUp;
      end;

    See also

    Float in Codebot.System.pas
    TSceneKeyArgs in Codebot.Render.Scenes.pas
    TSceneMouseArgs in Codebot.Render.Scenes.pas
    TSceneTextArgs in Codebot.Render.Scenes.pas