Skip to main content
Table of Contents

TTMSFNCToolBar.AddFontNamePicker Method

Creates and adds a TTMSFNCToolBarFontNamePicker to the toolbar.

API unit family: TMSFNCToolBar Declaring type: TTMSFNCToolBar Inherited from: TTMSFNCCustomToolBar

Syntax

FMX.TMSFNCToolBar.hppPascalC++
function AddFontNamePicker(AIndex: Integer = -1): TTMSFNCToolBarFontNamePicker; virtual;
virtual TTMSFNCToolBarFontNamePicker* __fastcall AddFontNamePicker(int AIndex = 0xffffffff);

Parameters

Name Description
AIndex Zero-based insertion index, or -1 to append.

Returns

The newly created font name picker.

Usage examples

Add the five built-in toolbar pickers

Adds font-name, font-size, color, bitmap, and generic item pickers, each wired to its typed selection event.

Add the five built-in toolbar pickersPascalC++
procedure TForm1.AddPickers;
var
  fontName: TTMSFNCToolBarFontNamePicker;
  fontSize: TTMSFNCToolBarFontSizePicker;
  textColor: TTMSFNCToolBarColorPicker;
  bullet: TTMSFNCToolBarBitmapPicker;
  zoom: TTMSFNCToolBarItemPicker;
begin
  // Font name picker: a dropdown of installed font families.
  // Editable lets the user type a family name instead of only picking one.
  fontName := TMSFNCToolBar1.AddFontNamePicker;
  fontName.Editable := True;
  fontName.OnFontNameSelected := FontNamePicked;

  // Font size picker: a dropdown of point sizes. SelectedFontSize is a Single.
  fontSize := TMSFNCToolBar1.AddFontSizePicker;
  fontSize.SelectedFontSize := 11;
  fontSize.OnFontSizeSelected := FontSizePicked;

  // Color picker: opens a color selector; SelectedColor is a TTMSFNCGraphicsColor.
  textColor := TMSFNCToolBar1.AddColorPicker;
  textColor.SelectedColor := gcBlack;
  textColor.OnColorSelected := ColorPicked;

  // Bitmap picker: opens a grid of bitmaps and returns the chosen one.
  bullet := TMSFNCToolBar1.AddBitmapPicker;
  bullet.OnBitmapSelected := BitmapPicked;

  // Generic item picker: your own dropdown list (here, zoom levels).
  zoom := TMSFNCToolBar1.AddItemPicker;
  zoom.Items.Add('50%');
  zoom.Items.Add('100%');
  zoom.Items.Add('150%');
  zoom.SelectedItemIndex := 1;
  zoom.OnItemSelected := ZoomPicked;

  TMSFNCToolBar1.Build;
end;

procedure TForm1.FontNamePicked(Sender: TObject; AFontName: string);
begin
  Memo1.TextSettings.Font.Family := AFontName;
end;

procedure TForm1.FontSizePicked(Sender: TObject; AFontSize: Single);
begin
  Memo1.TextSettings.Font.Size := AFontSize;
end;

procedure TForm1.ColorPicked(Sender: TObject; AColor: TTMSFNCGraphicsColor);
begin
  Memo1.TextSettings.FontColor := AColor;
end;

procedure TForm1.BitmapPicked(Sender: TObject; ABitmap: TTMSFNCBitmap);
begin
  { Apply the chosen bitmap, e.g. insert it as a bullet glyph in your document. }
end;

procedure TForm1.ZoomPicked(Sender: TObject; AItemIndex: Integer);
begin
  { AItemIndex is the selected row in the picker's Items list (0 = 50%, 1 = 100%). }
end;
void __fastcall TForm1::AddPickers()
{
  // Font name picker: a dropdown of installed font families.
  // Editable lets the user type a family name instead of only picking one.
  TTMSFNCToolBarFontNamePicker *fontName = TMSFNCToolBar1->AddFontNamePicker();
  fontName->Editable = true;
  fontName->OnFontNameSelected = FontNamePicked;

  // Font size picker: a dropdown of point sizes. SelectedFontSize is a Single.
  TTMSFNCToolBarFontSizePicker *fontSize = TMSFNCToolBar1->AddFontSizePicker();
  fontSize->SelectedFontSize = 11;
  fontSize->OnFontSizeSelected = FontSizePicked;

  // Color picker: opens a color selector; SelectedColor is a TTMSFNCGraphicsColor.
  TTMSFNCToolBarColorPicker *textColor = TMSFNCToolBar1->AddColorPicker();
  textColor->SelectedColor = gcBlack;
  textColor->OnColorSelected = ColorPicked;

  // Bitmap picker: opens a grid of bitmaps and returns the chosen one.
  TTMSFNCToolBarBitmapPicker *bullet = TMSFNCToolBar1->AddBitmapPicker();
  bullet->OnBitmapSelected = BitmapPicked;

  // Generic item picker: your own dropdown list (here, zoom levels).
  TTMSFNCToolBarItemPicker *zoom = TMSFNCToolBar1->AddItemPicker();
  zoom->Items->Add("50%");
  zoom->Items->Add("100%");
  zoom->Items->Add("150%");
  zoom->SelectedItemIndex = 1;
  zoom->OnItemSelected = ZoomPicked;

  TMSFNCToolBar1->Build();
}

void __fastcall TForm1::FontNamePicked(TObject *Sender, System::UnicodeString AFontName)
{
  Memo1->TextSettings->Font->Family = AFontName;
}

void __fastcall TForm1::FontSizePicked(TObject *Sender, float AFontSize)
{
  Memo1->TextSettings->Font->Size = AFontSize;
}

void __fastcall TForm1::ColorPicked(TObject *Sender, TTMSFNCGraphicsColor AColor)
{
  Memo1->TextSettings->FontColor = AColor;
}

void __fastcall TForm1::BitmapPicked(TObject *Sender, TTMSFNCBitmap *ABitmap)
{
  // Apply the chosen bitmap, e.g. insert it as a bullet glyph in your document.
}

void __fastcall TForm1::ZoomPicked(TObject *Sender, int AItemIndex)
{
  // AItemIndex is the selected row in the picker's Items list (0 = 50%, 1 = 100%).
}

Read the related guide