Skip to content

TStyledToolButton - Technical Reference ​

Overview ​

TStyledToolButton is the button of the TStyledToolbar. It is a styled graphic button (no window handle, no keyboard focus) that adds the toolbar behaviours of the VCL TToolButton: push, check, drop-down, separator and divider. See the component page for an introduction.

Class Hierarchy ​

TGraphicControl
  └─ TCustomStyledGraphicButton
      └─ TStyledToolButton

TStyledToolButton derives directly from TCustomStyledGraphicButton (the base of TStyledGraphicButton), so it has all its styling features and rendering (TStyledButtonRender); only the toolbar specific members are described in detail here. For the inherited ones see TStyledGraphicButton-Reference.

Unit ​

pascal
Vcl.StyledToolbar

Description ​

A button inherits the style of its toolbar (StyleFamily, StyleClass, StyleAppearance, StyleDrawType, StyleRadius, Images, Flat, Cursor) and follows it while it has the same value; assigning a different value overrides the toolbar for that button. Size, hint and events are those of any control.

Toolbar-specific published properties ​

PropertyTypeDefaultDescription
StyleTToolButtonStyletbsButtontbsButton, tbsCheck, tbsDropDown, tbsSeparator, tbsDivider. tbsTextButton raises an exception
GroupedBooleanFalseWith tbsCheck, the button belongs to a group of adjacent buttons that work as radio buttons
MarkedBooleanFalseKept for TToolButton compatibility (no visual effect)
MenuItemTMenuItemnilCopies Action, Caption, Down (from Checked), Enabled, Hint, ImageIndex, ImageName, Visible from the menu item
SortOrderInteger-1Position used by TStyledToolbar.SortBySortOrder
AutoSizeBooleanFalseWhen changed the toolbar recalculates the buttons
WrapBooleanFalseThe WordWrap of the caption (not a toolbar row wrap)
IndexIntegerPosition of the button in the toolbar (read-only, -1 without toolbar)
WidthIntegertoolbar ButtonWidthWidth; not stored when it is the one of the toolbar (separator: 6)
HeightIntegertoolbar ButtonHeightHeight
ImageAlignmentTImageAlignmentiaTopPosition of the image when the toolbar has ShowCaptions and not List (with List it is on the left, without captions centered)
EnabledBooleanTrueAlways False for separators and dividers

Styling (inherited, same name of the toolbar) ​

PropertyTypeDescription
StyleFamily, StyleClass, StyleAppearancestringFamily / Class / Appearance; stored only if different from the toolbar
StyleDrawTypeTStyledButtonDrawTypeShape (ignored for separators)
StyleRadiusIntegerCorner radius (default: the one of the toolbar)
StyleShadowSizeIntegerShadow (default: the one of the toolbar)
StyleRoundedCornersTRoundedCornersRounded corners (default: all)
StyleNamestringPer-control VCL Style (Delphi 10.4+)
StyleElementsTStyleElementsParts that follow the VCL Style
ButtonStyleNormal, ButtonStylePressed, ButtonStyleSelected, ButtonStyleHot, ButtonStyleDisabledTStyledButtonAttributesColours and border of each state
AsVCLComponentBooleanLooks like a VCL button of the active VCL Style (not stored)
TransparentBooleanTransparent background
FlatBooleanFlat button (default: the one of the toolbar)
CursorTCursorCursor (default: ButtonsCursor of the toolbar)

Caption and images (inherited) ​

PropertyTypeDescription
CaptionTCaptionShown only if the toolbar has ShowCaptions; not stored for separators
CaptionAlignmentTAlignmentAlignment of the caption
WordWrapBooleanWrap of the caption (not stored; use Wrap)
CommandLinkHintstringHint text of a command link
Images, DisabledImagesTCustomImageListImage lists (default: the ones of the toolbar)
ImageIndex, HotImageIndex, PressedImageIndex, SelectedImageIndex, DisabledImageIndexTImageIndexImage of each state (default -1)
ImageName, HotImageName, PressedImageName, SelectedImageName, DisabledImageNameTImageNameImage by name (Delphi 10.4+)
ImageMarginsTImageMarginsMargins of the image
Glyph, NumGlyphsTBitmap, TNumGlyphsBitmap glyph (TBitBtn compatibility)
KindTBitBtnKindTBitBtn kind (default bkCustom)

Behaviour (inherited) ​

PropertyTypeDescription
DownBooleanPressed state of a tbsCheck button
AllowAllUpBooleanIn a group, all the buttons can be up
DropDownMenuTPopupMenuMenu of a tbsDropDown button (or shown on click for the other styles)
ModalResultTModalResultModal result of the parent form
ActionTBasicActionLinked action
PopupMenuTPopupMenuContext menu
NotificationBadgeTNotificationBadgeAttributesBadge: see Notification-Badge-guide

Standard properties ​

Align, Anchors, Constraints, DragCursor, DragKind, DragMode, Font, ParentFont, ParentShowHint, ShowHint, Tag, Visible.

Public members (inherited) ​

MemberDescription
GroupIndex: IntegerGroup of the button (set to -1 by Grouped)
AutoClick, AutoClickDelayAutomatic click after a delay: see AutoClick-Delay-guide
Layout, Margin, SpacingPosition of the glyph (TSpeedButton compatibility; not published here)
ActiveStyleName: stringName of the active VCL Style (read-only)
ButtonState, MouseInControl, Focused, Render, StyleAppliedState and render object (read-only)
procedure SetButtonStyle(const AStyleFamily, AStyleClass, AStyleAppearance)Sets Family/Class/Appearance in one call (an empty value keeps the current one)
procedure SetButtonStyle(const AStyleFamily; const AModalResult: TModalResult)Chooses Class and Appearance by ModalResult
procedure AssignStyleTo(ADest)Copies the style to another button or render
function AssignAttributes(...)Sets enabled, images, action, OnClick and name in one call
procedure ShowDropDownMenu, DoDropDownMenuShows the DropDownMenu
procedure BeginUpdate, EndUpdateBatch changes without repaint
function GetSplitButtonWidth: IntegerWidth of the arrow of a drop-down button
constructor CreateStyled(AOwner; AFamily; AClass; AAppearance)Creates a styled button
class procedure RegisterDefaultRenderingStyle(...)Defaults of the buttons (inherited; the toolbar has its own)
procedure ClickShows the drop-down menu for a button with DropDownMenu, else fires OnClick and the OnToolButtonClick of the toolbar
procedure SetBounds(ALeft, ATop, AWidth, AHeight)At design time, resizing a button changes ButtonWidth/ButtonHeight of the toolbar

Events ​

EventDescription
OnClickThe button was clicked
OnDropDownClickArrow of a drop-down button clicked (before the menu is shown)
OnMouseDown, OnMouseUp, OnMouseMove, OnMouseEnter, OnMouseLeave, OnMouseActivateMouse events
OnContextPopup, OnGestureContext menu and touch
OnDragDrop, OnDragOver, OnEndDrag, OnStartDrag, OnStartDock, OnEndDockDrag and docking

Button styles (Style) ​

ValueDescription
tbsButtonNormal push button
tbsCheckToggle button (stays down); drawn pressed when Down
tbsDropDownSplit button with DropDownMenu
tbsSeparatorEmpty space, always disabled, without image and caption
tbsDividerAs separator, to divide groups

Usage Examples ​

pascal
var
  LButton: TStyledToolButton;
begin
  if Toolbar.NewButton(LButton) then
  begin
    LButton.Caption := 'Save';
    LButton.ImageIndex := 5;
    LButton.Hint := 'Save file';
    LButton.ShowHint := True;
    LButton.OnClick := SaveClick;
  end;

  //Check button of a radio group
  if Toolbar.NewButton(LButton, tbsCheck) then
    LButton.Grouped := True;

  //Own style (overrides the toolbar)
  LButton.SetButtonStyle(BOOTSTRAP_FAMILY, btn_primary, BOOTSTRAP_NORMAL);

  //Badge
  LButton.NotificationBadge.NotificationCount := 5;
end;

Important Notes ​

  • Parent: designed for a TStyledToolbar; NewButton is the preferred way to create it at run-time.
  • Size: from ButtonWidth / ButtonHeight of the toolbar; the toolbar resizes the buttons when they change.
  • Caption visibility: controlled by ShowCaptions of the toolbar.
  • No focus: as every graphic control it cannot receive keyboard focus.

See Also ​

Released under Apache License, Version 2.0.