Другой подход заключается в использовании StyleLookup. Используя StyleLookup, дизайнер может изменить стрелку, указывающую вниз, без изменения кода.
constructor TLFButton.Create(AOwner: TComponent);
begin
inherited;
FDropDownButton := true;
end;
procedure TLFButton.SetDropDownButton(const Value: boolean);
var
obj: TFmxObject;
begin
FDropDownButton := Value;
obj := FindStyleResource('dropdownbutton');
if obj is TControl then
TControl(obj).visible := Value;
end;
Сохраните приведенный ниже код в текстовом файле LFButton.Style и загрузите его в StyleBook. TPath = маленькая стрелка, указывающая вниз.
object _1: TLayout
Align = alClient
Position.Point = '(0,33)'
Width = 842.000000000000000000
Height = 715.000000000000000000
object TLayout
StyleName = 'LFButtonStyle'
Position.Point = '(375,345)'
Width = 91.000000000000000000
Height = 24.000000000000000000
DesignVisible = False
object TRectangle
StyleName = 'background'
Align = alContents
Width = 91.000000000000000000
Height = 24.000000000000000000
HitTest = False
Fill.Kind = bkGradient
Fill.Gradient.Points = <
item
Color = claWhite
end
item
Color = xFFFEFEFE
Offset = 0.472727268934249900
end
item
Color = xFFDDDDDD
Offset = 0.512727260589599600
end
item
Color = xFFDBDBDB
Offset = 1.000000000000000000
end>
Stroke.Color = xFF989898
XRadius = 3.000000000000000000
YRadius = 3.000000000000000000
object TGradientAnimation
Duration = 0.200000002980232200
Trigger = 'IsMouseOver=true;IsPressed=false'
StartValue.Points = <
item
Color = claWhite
end
item
Color = xFFFEFEFE
Offset = 0.472727268934249900
end
item
Color = xFFDDDDDD
Offset = 0.512727260589599600
end
item
Color = xFFDBDBDB
Offset = 1.000000000000000000
end>
StopValue.Points = <
item
Color = xFFA5D9FF
end
item
Color = xFFA5D9FF
Offset = 0.472727268934249900
end
item
Color = xFFA5D9FF
Offset = 0.512727260589599600
end
item
Color = xFFA5D9FF
Offset = 1.000000000000000000
end>
PropertyName = 'Fill.Gradient'
end
object TGradientAnimation
Duration = 0.200000002980232200
Trigger = 'IsMouseOver=false;IsPressed=false'
StartValue.Points = <
item
Color = xFFA5D9FF
end
item
Color = xFFA5D9FF
Offset = 0.472727268934249900
end
item
Color = xFFA5D9FF
Offset = 0.512727260589599600
end
item
Color = xFFA5D9FF
Offset = 1.000000000000000000
end>
StopValue.Points = <
item
Color = claWhite
end
item
Color = xFFFEFEFE
Offset = 0.472727268934249900
end
item
Color = xFFDDDDDD
Offset = 0.512727260589599600
end
item
Color = xFFDBDBDB
Offset = 1.000000000000000000
end>
PropertyName = 'Fill.Gradient'
end
object TColorAnimation
Duration = 0.200000002980232200
Inverse = True
Trigger = 'IsMouseOver=false;IsPressed=true'
StartValue = xFF34BFFE
StopValue = xFFA5D9FF
PropertyName = 'Fill.Color'
end
object TColorAnimation
Duration = 0.200000002980232200
Trigger = 'IsMouseOver=true;IsPressed=true'
StartValue = xFF34BFFE
StopValue = xFFA5D9FF
PropertyName = 'Fill.Color'
end
end
object TText
StyleName = 'text'
Align = alClient
Position.Point = '(5,3)'
Locked = True
Width = 66.000000000000000000
Height = 18.000000000000000000
Padding.Rect = '(5,3,5,3)'
HitTest = False
Text = 'button'
end
object TGlowEffect
Trigger = 'IsFocused=true'
Enabled = False
Softness = 0.200000002980232200
GlowColor = x82005ACC
Opacity = 0.899999976158142100
end
object TLayout
Align = alRight
Position.Point = '(76,0)'
Locked = True
Width = 15.000000000000000000
Height = 24.000000000000000000
object TPath
StyleName = 'dropdownbutton'
Align = alCenter
Position.Point = '(3,9)'
Width = 8.000000000000000000
Height = 5.000000000000000000
HitTest = False
Fill.Color = claBlack
Stroke.Kind = bkNone
Data.Path = {
04000000000000000000000000000000010000000000803F0000000001000000
0000003F0000803F030000000000000000000000}
end
end
end
end