vcl-cxbuttonedit-8629251e.md
The base class for button editor settings.
TcxCustomButtonEditProperties = class(
TcxCustomMaskEditProperties
)
A button editor is a single-line text editor with one or more embedded buttons and support for masked input.
The list below outlines key members of the TcxCustomButtonEditProperties class. These members allow you to configure button editors and manage their embedded buttons.
Alignment | UseLeftAlignmentOnEditingSpecify content alignment.ImagesSpecifies the image source for editor button glyphs.OnButtonGlyphDrawParametersAllows you to customize the appearance of editor button glyphs.
Provides access to UI Automation and accessibility-related settings.
Tip
Use Automation.Name, Automation.Description, and other API members to specify information visible to third-party assistive tools as UIA node properties.
AutoSelectSpecifies if the editor automatically selects content when input focus moves to the editor.Buttons | ButtonsViewStyleAllow you to manage and configure embedded editor buttonsClearKey | ClickKeyAllow you to associate keystrokes with basic user actions.OnButtonClickAllow you to execute custom code when a user clicks embedded editor buttons.ReadOnlyEnables or disables read-only mode. You can use the editor’s Style.ReadOnly and StyleReadOnly properties to customize editor appearance in read-only mode.
EchoModeAllows you to switch between normal and password input modes.EditFormat | DisplayFormat | UseDisplayFormatWhenEditingSpecify text format patterns in different editor states.HideCursorSpecifies if the caret is visible when the editor has focus.HideSelectionAllows you to disable the highlight effect for selected text when the editor loses focus.ImeMode | ImeNameAllow you to configure the input method editor (IME) for the text box.LookupItems | LookupItemsSorted | OnNewLookupDisplayText
Allow you to configure automatic completion for user input.
Note
These settings have no effect if a user input mask is defined for the editor.
Nullstring | UseNullStringAllow you to specify display text for the Null edit value.
IsMaskedIdentifies if a user input mask is applied to the editor.EditMask | MaskKindAllow you to configure a user input mask (with support for regular expressions).MaxLengthLimits the length of an input string.MaxValue | MinValueLimit the range of valid numeric values.
BeepOnErrorAllows you to play the standard system sound when a validation error occurs.ErrorIcon | ValidationErrorIconAlignmentSpecify and position an error icon.ValidateDisplayValue | ValidateOnEnter | CanValidate | OnValidate | IsEditValueValidAllow you to validate user input.ValidationOptionsSpecifies validation option flags.
AssignedValues | RestoreDefaultsAllow you to track the state of individual editor-specific settings and reset them.BeginUpdate | EndUpdate | LockUpdate | DoUpdate | Update | Changed | ChangedLocked | DataChangedAllow you to manage editor updates and avoid excessive redraw operations during batch editor setting changes.GetButtonsClass | GetContainerClass | GetStyleClass | GetViewInfoClassReturn editor property value types.
The code example below demonstrates OnButtonClick and OnCreate event handlers.
The application form’s OnCreate event handler creates two additional embedded buttons in a TcxButtonEdit control and configures the appearance and behavior of all embedded buttons. The OnButtonClick event handler associates all created buttons with the editor’s functionality.
Note
This example uses a TcxImageList component with three SVG icons as a source of glyphs for the created buttons.
procedure TMyForm.cxButtonEdit1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
var
AEditor: TcxButtonEdit;
begin
AEditor := Sender as TcxButtonEdit;
if AButtonIndex = 0 then // The first button clears the editor
AEditor.Clear
else if AButtonIndex = 1 then // The second button selects content
AEditor.SelectAll
else if AButtonIndex = 2 then // The third button hides or reveals content
begin
if AEditor.Properties.EchoMode = eemNormal then
AEditor.Properties.EchoMode := eemPassword
else
AEditor.Properties.EchoMode := eemNormal;
end;
end;
procedure TMyForm.FormCreate(Sender: TObject);
var
AProperties: TcxButtonEditProperties;
I: Integer;
begin
cxButtonEdit1.ShowHint := True; // Enables hints for the editor
AProperties := cxButtonEdit1.Properties;
AProperties.BeginUpdate; // Initiates the following batch change
try
AProperties.Images := cxImageList1; // Assigns the source of button glyphs
// Create two additional buttons
AProperties.Buttons.Add;
AProperties.Buttons.Add;
// Specify common button settings
for I := 0 to AProperties.Buttons.Count - 1 do
begin
AProperties.Buttons.Items[I].Kind := bkGlyph; // Changes the button content type to "glyph"
AProperties.Buttons.Items[I].ImageIndex := I; // Specifies image indexes in the source list
AProperties.Buttons.Items[I].HotTrackMode := TcxEditButtonHotTrackMode.Editor;
end;
// Specify unique button settings
AProperties.Buttons.Items[0].Hint := 'Clear';
AProperties.Buttons.Items[1].Hint := 'Select All';
AProperties.Buttons.Items[2].Hint := 'Hide/Reveal';
AProperties.Buttons.Items[2].LeftAlignment := True;
AProperties.Buttons.Items[2].Transparent := True;
finally
AProperties.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
void __fastcall TMyForm::cxButtonEdit1PropertiesButtonClick(TObject *Sender,
int AButtonIndex)
{
TcxButtonEdit *AEditor = dynamic_cast<TcxButtonEdit*>(Sender);
// ...
if(AButtonIndex == 0) // The first button clears the editor
AEditor->Clear();
else if(AButtonIndex == 1) // The second button selects content
AEditor->SelectAll();
else if(AButtonIndex == 2) // The third button hides or reveals content
{
if(AEditor->Properties->EchoMode == eemNormal)
AEditor->Properties->EchoMode = eemPassword;
else
AEditor->Properties->EchoMode = eemNormal;
}
}
void __fastcall TMyForm::FormCreate(TObject *Sender)
{
TcxButtonEditProperties *AProperties = cxButtonEdit1->Properties;
cxButtonEdit1->ShowHint = true; // Enables hints for the editor
AProperties->BeginUpdate(); // Initiates the following batch change
try
{
AProperties->Images = cxImageList1; // Assigns the source of button glyphs
// Create two additional buttons
AProperties->Buttons->Add();
AProperties->Buttons->Add();
// Specify common button settings
for(int i = 0; i < AProperties->Buttons->Count; i++)
{
AProperties->Buttons->Items[i]->Kind = bkGlyph; // Changes the button content type to "glyph"
AProperties->Buttons->Items[i]->ImageIndex = i; // Specifies image indexes in the source list
AProperties->Buttons->Items[i]->HotTrackMode = TcxEditButtonHotTrackMode::Editor;
}
// Specify unique button settings
AProperties->Buttons->Items[0]->Hint = "Clear";
AProperties->Buttons->Items[1]->Hint = "Select All";
AProperties->Buttons->Items[2]->Hint = "Hide/Reveal";
AProperties->Buttons->Items[2]->LeftAlignment = true;
AProperties->Buttons->Items[2]->Transparent = true;
}
__finally
{
AProperties->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
}
Do not use the TcxCustomButtonEditProperties class directly. Use the TcxButtonEditProperties class instead.
TObject TPersistent TInterfacedPersistent TcxInterfacedPersistent TcxCustomEditProperties TcxCustomTextEditProperties TcxCustomMaskEditProperties TcxCustomButtonEditProperties
See Also
TcxCustomButtonEdit.ActiveProperties Property
TcxCustomButtonEdit.Properties Property