Back to Devexpress

TcxCustomTextEditProperties.EchoMode Property

vcl-cxtextedit-dot-tcxcustomtexteditproperties-136bf17b.md

latest6.0 KB
Original Source

TcxCustomTextEditProperties.EchoMode Property

Specifies the text display mode.

Declaration

delphi
property EchoMode: TcxEditEchoMode read; write; default eemNormal;

Property Value

TypeDefaultDescription
TcxEditEchoModeeemNormal

The active text display mode.

|

Remarks

The EchoMode property value only affects the appearance of displayed text and has no effect on the editor value. Refer to the TcxEditEchoMode type description for detailed information on available options.

Note

The EchoMode property affects both user input text and text inserted programmatically.

Code Example: Switch Between Normal and Password Input Modes

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.

delphi
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;
cpp
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
  }
}

Default Value

The EchoMode property’s default value is eemNormal.

See Also

TcxCustomTextEditProperties.PasswordChar

TcxCustomTextEditProperties.PasswordChar

TcxCustomTextEditProperties Class

TcxCustomTextEditProperties Members

cxTextEdit Unit