Now I will list the common methods, properties and events of all input fields (i.e., related mainly to objects for editing plain text - memo, and rich text - rich edit):
Text - (same as Caption). Yes, I already mentioned this property among the most common for all visual objects. But for the input field, it will not be superfluous to remind about the existence of such a property that provides access to all editable and displayed text at once, returning it on one line (and allowing you to change all the text by assigning a line to this property);
TextSize - the size of the text in bytes. For formatted text, returns the size of the text without regard to formatting. (See also the RE_TextSize property);
SelStart - the position of the beginning of the selection area (character index in the general array of text characters, starting from zero). If the selection is not empty, then this will be the index of the first selected character. With an empty selection, the SelStart property still has a value - as the current input position in the text (visualized by a blinking caret). And then it indicates the index of the character, before which the new characters entered from the keyboard will be typed;
SelLength - the length of the selected text fragment (I don't need to explain here why the text is selected in general, right?);
Selection - a string property representing the current selection (you can read it to get the selection, or assign another string to this property to replace the entire selection). For a formatted text input field, this property represents the selected text in unformatted form; to get a formatted selection, use the specialized RE_Text property;
ReplaceSelection(s, canundo) - allows you to replace the current selection with string s, and additionally indicate that this operation will go to the rollback stack (i.e. if the parameter canundo = true, then this operation can be canceled);
SelectAll - when called, makes all the text in the field selected;
DeleteLines(i1, i2) - deletes lines in the specified range;
Item2Pos(i) - for a given line index, returns the position of its first character in the text (0 is returned for a single-line input field);
Pos2Item(i) - for a given position in the text, the index of the line to which this character belongs is returned;
EditTabChar - "pass-through" method, which ensures the typing of a tab character in the text when the Tab key is pressed (including for fields for which the eoWantTab option was not specified during creation);
Ed_Transparent - allows you to make the input field of plain text (not formatted) almost completely "transparent". Can be used to achieve special visual effects (for example, if the parent of the input field is a gradient bar);
OnChange - this event is triggered when there is any change in the text.
|
Note that the OnSelChange event does not make sense for an input field and does not fire; if you need to track changes in the carriage position and text selection, you should process keyboard and mouse messages, as a result of which the specified parameters change. Moreover, since these changes occur after the event has been processed, in the handler itself, you should send a user message to yourself using PostMsg, and catch this message; |
CanUndo - checks if the undo operation can be performed now;
EmptyUndoBuffer - clears the rollback stack (after which it becomes impossible to rollback the changes made, and the CanUndo method returns false);
Undo - rolls back one performed change (see also RE_Redo).