Event disappears on button Style designer

253 views Asked by At

I would like to create a personalized style on expander in firemonkey. But when I want to add an event on a button (I replace the checkbox by a button that I have drag and drop from palette), then when I save, the event disappear and is not triggered.

What am I doing wrong ?

Thanks in advance.

EDIT : enter image description here

When I create/select an event from the dropdownmenu, when I saved the style, the selected event diseaper from the onclick event but my code is always written

EDIT 2 :

I have an Expander, and I would like to replace the default Checkbox by a Button.

So, I Edit the Default Style and replace the default Checkbox by a SpeedButton (like in the picture above)

At this Button, I want to add an Event on the OnClick. So I double click on the empty space beside the OnClick event and write the code into this event created automatically.

Once my code written, I'm go back in the Style Designer and I see the Event attached to the OnClick button, then I save the style.

But when I return to the Style Designer, the Event is not attached anymore to the Onclick event but he's still write/exist in code.

I tell myself I made a wrong saved, but the button him is still here, so I for me It's really saved.

I hope I'm clear. enter image description here

LAST EDIT :

    object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 480
  ClientWidth = 640
  StyleBook = StyleBook1
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object Expander1: TExpander
    Align = Client
    ShowCheck = False
    Size.Width = 640.000000000000000000
    Size.Height = 480.000000000000000000
    Size.PlatformDefault = False
    StyleLookup = 'Expander1Style1'
    Text = 'Expander1'
    TabOrder = 0
    ContentSize = '455'
  end
  object StyleBook1: TStyleBook
    Styles = <
      item
      end
      item
        Platform = 'Windows 10 Desktop'
        ResourcesBin = {
          464D585F5354594C4520322E3501060F457870616E646572315374796C653103
          D9030623457870616E646572315374796C6531457870616E646572427574746F
          6E5374796C6531037E0F061D457870616E646572315374796C6531436865636B
          426F785374796C653103D00B005450463007544C61796F757400095374796C65
          4E616D65060F457870616E646572315374796C653105416C69676E070643656E
          7465720A53697A652E57696474680500000000000000A008400B53697A652E48
          65696768740500000000000000F007401453697A652E506C6174666F726D4465
          6661756C7408085461624F726465720251000A5452656374616E676C65000541
          6C69676E0708436F6E74656E74730A46696C6C2E436F6C6F7207097846464630
          463046300748697454657374080A53697A652E57696474680500000000000000
          A008400B53697A652E4865696768740500000000000000F007401453697A652E
          506C6174666F726D44656661756C74080C5374726F6B652E436F6C6F72070978
          46464343434343430007544C61796F757400095374796C654E616D6506066865
          6164657205416C69676E0703546F700A53697A652E5769647468050000000000
          0000A008400B53697A652E4865696768740500000000000000C803401453697A
          652E506C6174666F726D44656661756C74080005545465787400095374796C65
          4E616D6506047465787405416C69676E0706436C69656E74064C6F636B656409
          0748697454657374080C4D617267696E732E4C65667405000000000000008000
          400D4D617267696E732E526967687405000000000000008000400A53697A652E
          576964746805000000000000809208400B53697A652E48656967687405000000
          00000000C803401453697A652E506C6174666F726D44656661756C7408045465
          7874060454657874155465787453657474696E67732E576F7264577261700800
          000F54457870616E646572427574746F6E00095374796C654E616D6506066275
          74746F6E05416C69676E07084D6F73744C656674064C6F636B6564090A53697A
          652E57696474680500000000000000C803400B53697A652E4865696768740500
          000000000000C803401453697A652E506C6174666F726D44656661756C74080B
          5374796C654C6F6F6B75700623457870616E646572315374796C653145787061
          6E646572427574746F6E5374796C653100000C545370656564427574746F6E0C
          62746E416464416374696F6E095374796C654E616D6506115370656564427574
          746F6E315374796C6505416C69676E07094D6F737452696768740A506F736974
          696F6E2E5805000000000000C09908400A53697A652E57696474680500000000
          000000C803400B53697A652E4865696768740500000000000000C80340145369
          7A652E506C6174666F726D44656661756C74080B5374796C654C6F6F6B757006
          0D6164646974656D627574746F6E0454657874060C62746E416464416374696F
          6E00000000005450463007544C61796F757400095374796C654E616D65062345
          7870616E646572315374796C6531457870616E646572427574746F6E5374796C
          65310A53697A652E57696474680500000000000000A008400B53697A652E4865
          696768740500000000000000F007401453697A652E506C6174666F726D446566
          61756C74080756697369626C6508085461624F72646572025200125442757474
          6F6E5374796C654F626A65637400095374796C654E616D65060A6261636B6772
          6F756E6405416C69676E070643656E746572074F706163697479050000000000
          00000000000C536F757263654C6F6F6B7570061B57696E646F77732031302044
          65736B746F707374796C652E706E670A53697A652E5769647468050000000000
          0000D002400B53697A652E4865696768740500000000000000D002401453697A
          652E506C6174666F726D44656661756C740808577261704D6F6465070643656E
          74657207486F744C696E6B0E010F536F75726365526563742E4C656674050000
          0000000000FA05400E536F75726365526563742E546F7005000000000000009E
          074010536F75726365526563742E526967687405000000000000008A06401153
          6F75726365526563742E426F74746F6D0500000000000080A407400001055363
          616C650500000000000000C0FF3F0F536F75726365526563742E4C6566740500
          000000000000BC06400E536F75726365526563742E546F700500000000000000
          ED074010536F75726365526563742E52696768740500000000000000D0064011
          536F75726365526563742E426F74746F6D0500000000000000F7074000010553
          63616C6505000000000000008000400F536F75726365526563742E4C65667405
          00000000000000FA06400E536F75726365526563742E546F7005000000000000
          009E084010536F75726365526563742E526967687405000000000000008A0740
          11536F75726365526563742E426F74746F6D0500000000000080A4084000000B
          466F63757365644C696E6B0E010F536F75726365526563742E4C656674050000
          0000000000DC05400E536F75726365526563742E546F7005000000000000009E
          074010536F75726365526563742E52696768740500000000000000F605401153
          6F75726365526563742E426F74746F6D0500000000000080A407400001055363
          616C650500000000000000C0FF3F0F536F75726365526563742E4C6566740500
          000000000000A506400E536F75726365526563742E546F700500000000000000
          ED074010536F75726365526563742E52696768740500000000000000B9064011
          536F75726365526563742E426F74746F6D0500000000000000F7074000010553
          63616C6505000000000000008000400F536F75726365526563742E4C65667405
          00000000000000DC06400E536F75726365526563742E546F7005000000000000
          009E084010536F75726365526563742E52696768740500000000000000F60640
          11536F75726365526563742E426F74746F6D0500000000000080A4084000000A
          4E6F726D616C4C696E6B0E010F536F75726365526563742E4C65667405000000
          00000000DC05400E536F75726365526563742E546F7005000000000000009E07
          4010536F75726365526563742E52696768740500000000000000F6054011536F
          75726365526563742E426F74746F6D0500000000000080A40740000105536361
          6C650500000000000000C0FF3F0F536F75726365526563742E4C656674050000
          0000000000A506400E536F75726365526563742E546F700500000000000000ED
          074010536F75726365526563742E52696768740500000000000000B906401153
          6F75726365526563742E426F74746F6D0500000000000000F707400001055363
          616C6505000000000000008000400F536F75726365526563742E4C6566740500
          000000000000DC06400E536F75726365526563742E546F700500000000000000
          9E084010536F75726365526563742E52696768740500000000000000F6064011
          536F75726365526563742E426F74746F6D0500000000000080A4084000000B50
          7265737365644C696E6B0E010F536F75726365526563742E4C65667405000000
          00000000FA05400E536F75726365526563742E546F7005000000000000009E07
          4010536F75726365526563742E526967687405000000000000008A064011536F
          75726365526563742E426F74746F6D0500000000000080A40740000105536361
          6C650500000000000000C0FF3F0F536F75726365526563742E4C656674050000
          0000000000BC06400E536F75726365526563742E546F700500000000000000ED
          074010536F75726365526563742E52696768740500000000000000D006401153
          6F75726365526563742E426F74746F6D0500000000000000F707400001055363
          616C6505000000000000008000400F536F75726365526563742E4C6566740500
          000000000000FA06400E536F75726365526563742E546F700500000000000000
          9E084010536F75726365526563742E526967687405000000000000008A074011
          536F75726365526563742E426F74746F6D0500000000000080A4084000001354
          6F756368416E696D6174696F6E2E4C696E6B0E00000F54466C6F6174416E696D
          6174696F6E00084475726174696F6E05000000000017B7D1F13F0C50726F7065
          7274794E616D6506074F7061636974790A537461727456616C75650500000000
          0000000000000953746F7056616C7565050000000000000080FF3F0754726967
          67657206104973457870616E6465643D66616C73650E54726967676572496E76
          65727365060F4973457870616E6465643D747275650000001254427574746F6E
          5374796C654F626A65637400095374796C654E616D65060A6261636B67726F75
          6E6405416C69676E070643656E7465720C536F757263654C6F6F6B7570061B57
          696E646F7773203130204465736B746F707374796C652E706E670A53697A652E
          57696474680500000000000000D002400B53697A652E48656967687405000000
          00000000D002401453697A652E506C6174666F726D44656661756C7408085772
          61704D6F6465070643656E74657207486F744C696E6B0E010F536F7572636552
          6563742E4C6566740500000000000000FA05400E536F75726365526563742E54
          6F70050000000000000095074010536F75726365526563742E52696768740500
          0000000000008A064011536F75726365526563742E426F74746F6D0500000000
          0000809B07400001055363616C650500000000000000C0FF3F0F536F75726365
          526563742E4C6566740500000000000000BC06400E536F75726365526563742E
          546F700500000000000080DF074010536F75726365526563742E526967687405
          00000000000000D0064011536F75726365526563742E426F74746F6D05000000
          00000080E907400001055363616C6505000000000000008000400F536F757263
          65526563742E4C6566740500000000000000FA06400E536F7572636552656374
          2E546F70050000000000000095084010536F75726365526563742E5269676874
          05000000000000008A074011536F75726365526563742E426F74746F6D050000
          00000000809B084000000B466F63757365644C696E6B0E010F536F7572636552
          6563742E4C6566740500000000000000DC05400E536F75726365526563742E54
          6F70050000000000000095074010536F75726365526563742E52696768740500
          000000000000F6054011536F75726365526563742E426F74746F6D0500000000
          0000809B07400001055363616C650500000000000000C0FF3F0F536F75726365
          526563742E4C6566740500000000000000A506400E536F75726365526563742E
          546F700500000000000080DF074010536F75726365526563742E526967687405
          00000000000000B9064011536F75726365526563742E426F74746F6D05000000
          00000080E907400001055363616C6505000000000000008000400F536F757263
          65526563742E4C6566740500000000000000DC06400E536F7572636552656374
          2E546F70050000000000000095084010536F75726365526563742E5269676874
          0500000000000000F6064011536F75726365526563742E426F74746F6D050000
          00000000809B084000000A4E6F726D616C4C696E6B0E010F536F757263655265
          63742E4C6566740500000000000000DC05400E536F75726365526563742E546F
          70050000000000000095074010536F75726365526563742E5269676874050000
          0000000000F6054011536F75726365526563742E426F74746F6D050000000000
          00809B07400001055363616C650500000000000000C0FF3F0F536F7572636552
          6563742E4C6566740500000000000000A506400E536F75726365526563742E54
          6F700500000000000080DF074010536F75726365526563742E52696768740500
          000000000000B9064011536F75726365526563742E426F74746F6D0500000000
          000080E907400001055363616C6505000000000000008000400F536F75726365
          526563742E4C6566740500000000000000DC06400E536F75726365526563742E
          546F70050000000000000095084010536F75726365526563742E526967687405
          00000000000000F6064011536F75726365526563742E426F74746F6D05000000
          000000809B084000000B507265737365644C696E6B0E010F536F757263655265
          63742E4C6566740500000000000000FA05400E536F75726365526563742E546F
          70050000000000000095074010536F75726365526563742E5269676874050000
          00000000008A064011536F75726365526563742E426F74746F6D050000000000
          00809B07400001055363616C650500000000000000C0FF3F0F536F7572636552
          6563742E4C6566740500000000000000BC06400E536F75726365526563742E54
          6F700500000000000080DF074010536F75726365526563742E52696768740500
          000000000000D0064011536F75726365526563742E426F74746F6D0500000000
          000080E907400001055363616C6505000000000000008000400F536F75726365
          526563742E4C6566740500000000000000FA06400E536F75726365526563742E
          546F70050000000000000095084010536F75726365526563742E526967687405
          000000000000008A074011536F75726365526563742E426F74746F6D05000000
          000000809B0840000013546F756368416E696D6174696F6E2E4C696E6B0E0000
          0F54466C6F6174416E696D6174696F6E00084475726174696F6E050000000000
          17B7D1F13F0C50726F70657274794E616D6506074F7061636974790A53746172
          7456616C756505000000000000000000000953746F7056616C75650500000000
          00000080FF3F0754726967676572060F4973457870616E6465643D747275650E
          54726967676572496E766572736506104973457870616E6465643D66616C7365
          000000005450463007544C61796F757400095374796C654E616D65061D457870
          616E646572315374796C6531436865636B426F785374796C65310A53697A652E
          57696474680500000000000000A008400B53697A652E48656967687405000000
          00000000F007401453697A652E506C6174666F726D44656661756C7408075669
          7369626C6508085461624F7264657202120007544C61796F75740005416C6967
          6E07044C6566740A53697A652E576964746805000000000000009003400B5369
          7A652E4865696768740500000000000000F007401453697A652E506C6174666F
          726D44656661756C7408001154436865636B5374796C654F626A656374000953
          74796C654E616D65060A6261636B67726F756E6405416C69676E070643656E74
          6572074361704D6F6465070454696C65064C6F636B6564090C536F757263654C
          6F6F6B7570061B57696E646F7773203130204465736B746F707374796C652E70
          6E670A53697A652E57696474680500000000000000D002400B53697A652E4865
          696768740500000000000000D002401453697A652E506C6174666F726D446566
          61756C740808577261704D6F6465070643656E7465720D416374697665547269
          676765720707436865636B65640A4163746976654C696E6B0E010F536F757263
          65526563742E4C6566740500000000000000F803400E536F7572636552656374
          2E546F70050000000000000092064010536F75726365526563742E5269676874
          0500000000000000B0044011536F75726365526563742E426F74746F6D050000
          00000000009F06400001055363616C650500000000000000C0FF3F0F536F7572
          6365526563742E4C6566740500000000000000B804400E536F75726365526563
          742E546F700500000000000000DB064010536F75726365526563742E52696768
          74050000000000000082054011536F75726365526563742E426F74746F6D0500
          000000000000EE06400001055363616C6505000000000000008000400F536F75
          726365526563742E4C6566740500000000000000F804400E536F757263655265
          63742E546F70050000000000000092074010536F75726365526563742E526967
          68740500000000000000B0054011536F75726365526563742E426F74746F6D05
          000000000000009F074000000A536F757263654C696E6B0E010F536F75726365
          526563742E4C6566740500000000000000C000400E536F75726365526563742E
          546F70050000000000000092064010536F75726365526563742E526967687405
          0000000000000080034011536F75726365526563742E426F74746F6D05000000
          000000009F06400001055363616C650500000000000000C0FF3F0F536F757263
          65526563742E4C65667405000000000000008001400E536F7572636552656374
          2E546F700500000000000000DB064010536F75726365526563742E5269676874
          0500000000000000B8034011536F75726365526563742E426F74746F6D050000
          0000000000EE06400001055363616C6505000000000000008000400F536F7572
          6365526563742E4C6566740500000000000000C001400E536F75726365526563
          742E546F70050000000000000092074010536F75726365526563742E52696768
          74050000000000000080044011536F75726365526563742E426F74746F6D0500
          0000000000009F0740000007486F744C696E6B0E010F536F7572636552656374
          2E4C65667405000000000000008803400E536F75726365526563742E546F7005
          0000000000000092064010536F75726365526563742E52696768740500000000
          000000F0034011536F75726365526563742E426F74746F6D0500000000000000
          9F06400001055363616C650500000000000000C0FF3F0F536F75726365526563
          742E4C6566740500000000000000C803400E536F75726365526563742E546F70
          0500000000000000DB064010536F75726365526563742E526967687405000000
          00000000B0044011536F75726365526563742E426F74746F6D05000000000000
          00EE06400001055363616C6505000000000000008000400F536F757263655265
          63742E4C65667405000000000000008804400E536F75726365526563742E546F
          70050000000000000092074010536F75726365526563742E5269676874050000
          0000000000F0044011536F75726365526563742E426F74746F6D050000000000
          00009F074000000D416374697665486F744C696E6B0E010F536F757263655265
          63742E4C6566740500000000000000B404400E536F75726365526563742E546F
          70050000000000000092064010536F75726365526563742E5269676874050000
          0000000000E8044011536F75726365526563742E426F74746F6D050000000000
          00009F06400001055363616C650500000000000000C0FF3F0F536F7572636552
          6563742E4C65667405000000000000008605400E536F75726365526563742E54
          6F700500000000000000DB064010536F75726365526563742E52696768740500
          000000000000AC054011536F75726365526563742E426F74746F6D0500000000
          000000EE06400001055363616C6505000000000000008000400F536F75726365
          526563742E4C6566740500000000000000B405400E536F75726365526563742E
          546F70050000000000000092074010536F75726365526563742E526967687405
          00000000000000E8054011536F75726365526563742E426F74746F6D05000000
          000000009F074000000B466F63757365644C696E6B0E010F536F757263655265
          63742E4C65667405000000000000008803400E536F75726365526563742E546F
          70050000000000000092064010536F75726365526563742E5269676874050000
          0000000000F0034011536F75726365526563742E426F74746F6D050000000000
          00009F06400001055363616C650500000000000000C0FF3F0F536F7572636552
          6563742E4C6566740500000000000000C803400E536F75726365526563742E54
          6F700500000000000000DB064010536F75726365526563742E52696768740500
          000000000000B0044011536F75726365526563742E426F74746F6D0500000000
          000000EE06400001055363616C6505000000000000008000400F536F75726365
          526563742E4C65667405000000000000008804400E536F75726365526563742E
          546F70050000000000000092074010536F75726365526563742E526967687405
          00000000000000F0044011536F75726365526563742E426F74746F6D05000000
          000000009F0740000011416374697665466F63757365644C696E6B0E010F536F
          75726365526563742E4C6566740500000000000000B404400E536F7572636552
          6563742E546F70050000000000000092064010536F75726365526563742E5269
          6768740500000000000000E8044011536F75726365526563742E426F74746F6D
          05000000000000009F06400001055363616C650500000000000000C0FF3F0F53
          6F75726365526563742E4C65667405000000000000008605400E536F75726365
          526563742E546F700500000000000000DB064010536F75726365526563742E52
          696768740500000000000000AC054011536F75726365526563742E426F74746F
          6D0500000000000000EE06400001055363616C6505000000000000008000400F
          536F75726365526563742E4C6566740500000000000000B405400E536F757263
          65526563742E546F70050000000000000092074010536F75726365526563742E
          52696768740500000000000000E8054011536F75726365526563742E426F7474
          6F6D05000000000000009F074000000000001654427574746F6E5374796C6554
          6578744F626A65637400095374796C654E616D6506047465787405416C69676E
          0706436C69656E74064C6F636B6564090C4D617267696E732E4C656674050000
          0000000000C000400A53697A652E576964746805000000000000C09A08400B53
          697A652E4865696768740500000000000000F007401453697A652E506C617466
          6F726D44656661756C74080D536861646F7756697369626C650808486F74436F
          6C6F720708636C61426C61636B0C466F6375736564436F6C6F720708636C6142
          6C61636B0B4E6F726D616C436F6C6F720708636C61426C61636B0C5072657373
          6564436F6C6F720708636C61426C61636B000000}
      end>
  end
end
1

There are 1 answers

0
Bruce On

You can't set an event in Style Designer. You should call FindStyleResource in the OnApplyStyleLookup event passing the StyleName of the object and return it as a TFMXObject, like this:

procedure TForm1.Expander1ApplyStyleLookup(Sender: TObject);
var
  Control: Sender as TFmxObject;
  O: TFMXObject;
  Button: TSpeedButton;
begin
  O := Control.FindStyleResource('btnAddAction');
  if (Assigned(O) and (O is TSpeedButton)) then
    Button := O as TSpeedButton;
    if (Assigned(Button)) then
      Button.OnClick = btnAddActionClick;
end;