TBaseItemEditText (Delphi)

From RAD Studio Code Examples

Description

This example shows how to edit TCategoryButtons Category and button captions. boFullSize and boShowCaptions must be true in the TCategoryButtons ButtonOptions.

Code

procedure TForm1.EditCurrCatClick(Sender: TObject);
begin
// This will allow categories and buttons to be edited.
// boFullSize and boShowCaptions must be true in the TCategoryButtons ButtonOptions.
  CategoryButtons1.CurrentCategory.CategoryButtons.SelectedItem.EditText;
end;

procedure TForm1.CategoryButtons1CancelEdit(Sender: TObject;
  const Button: TBaseItem);
begin
  Memo1.Lines.Add(Button.Caption + ' CancelEdit');
end;

procedure TForm1.CategoryButtonsItemsClick(Sender: TObject);
var
  cat: TButtonCategory;
  item: TBaseItem;
begin
  cat:= (Sender as TCategoryButtons).CurrentCategory;
  item:= cat.CategoryButtons.SelectedItem;
  Memo1.Lines.Add(cat.Caption + ' ' + item.Caption + ' CategoryButtonsItemsClicking');
end;

procedure TForm1.CategoryButtons1Edited(Sender: TObject; Item: TBaseItem;
  var S: string);
begin
  // When you edit the category, the caption is not new by the time OnEdited is called.'
  Memo1.Lines.Add(Item.Caption + ' Edited');
end;

procedure TForm1.CategoryButtons1Editing(Sender: TObject; Item: TBaseItem;
  var AllowEdit: Boolean);
begin
  Memo1.Lines.Add(Item.Caption + ' Editing');
end;

procedure TForm1.EditItem1Click(Sender: TObject);
begin
// Edits the current category
  CategoryButtons1.CurrentCategory.EditText;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  PopupMenu1.Popup(Left + X, Top + Y);
end;

Uses