Recent

Author Topic: About Buttons/ExCtrls and cocoa  (Read 750 times)

bigeno

  • Sr. Member
  • ****
  • Posts: 264
About Buttons/ExCtrls and cocoa
« on: April 01, 2022, 09:14:26 pm »
Hi,
I need help with exctrls @wp.
I've some problems with porting one of my projects to Mac os on cocoa. For some reasone there is no captions on buttons (same for design mode and productuion).
Can anyone advise ?
---edit

What I observed is when creating a new project the text on the button is only in design mode, after closing the project and reopening the button text is no longer there (design mode).
Looks like something is being removed from the lfm ?
« Last Edit: April 01, 2022, 09:42:05 pm by bigeno »

AlexTP

  • Hero Member
  • *****
  • Posts: 1957
    • UVviewsoft
Re: About Buttons/ExCtrls and cocoa
« Reply #1 on: April 01, 2022, 09:47:00 pm »
Provide a simple compilable test project, please.

bigeno

  • Sr. Member
  • ****
  • Posts: 264
Re: About Buttons/ExCtrls and cocoa
« Reply #2 on: April 01, 2022, 10:01:07 pm »
Provide a simple compilable test project, please.
the problem is with new/empty project also.
Attached example.

wp

  • Hero Member
  • *****
  • Posts: 10281
Re: About Buttons/ExCtrls and cocoa
« Reply #3 on: April 01, 2022, 11:05:22 pm »
I see... It looks to me that the mac button is very strict regarding custom painting. The debugger shows me that the painting routine is entered and every command is called - but finally is not executed at all.

However, since I don't work on mac except for some occasional compilation tests and simple bug fixes I am afraid that I cannot do much about it. Maybe a more experienced user can help?


bigeno

  • Sr. Member
  • ****
  • Posts: 264
Re: About Buttons/ExCtrls and cocoa
« Reply #4 on: April 02, 2022, 02:42:13 pm »
I see... It looks to me that the mac button is very strict regarding custom painting. The debugger shows me that the painting routine is entered and every command is called - but finally is not executed at all.

However, since I don't work on mac except for some occasional compilation tests and simple bug fixes I am afraid that I cannot do much about it. Maybe a more experienced user can help?
yes, the problem is with caption and colors also (whole painting). For captions I found this will work:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   TCustomButton(ButtonEx1).Caption:='test';
  4. end;

wp

  • Hero Member
  • *****
  • Posts: 10281
Re: About Buttons/ExCtrls and cocoa
« Reply #5 on: April 02, 2022, 07:16:13 pm »
Ah I see. In the SetCaption setter method, there is this code:

Code: Pascal  [Select][+][-]
  1. procedure TButtonEx.SetCaption(const AValue: String);
  2. begin
  3.   if FCaption = AValue then
  4.     exit;
  5.   inherited Caption := '';  
  6.   FCaption := AValue;
  7.   Invalidate;
  8. end;

This erases the inherited Caption and assumes that it is replaced by the new caption (FCaption). I do remember that the control did not work with all its features when the inherited Caption was not empty. And I found an old forum post in which I reported several issues with TButtonEx: https://forum.lazarus.freepascal.org/index.php/topic,50179.msg366185.html

So, my advice: don't use TButtonEx on cocoa... Sorry.

AlexTP

  • Hero Member
  • *****
  • Posts: 1957
    • UVviewsoft
Re: About Buttons/ExCtrls and cocoa
« Reply #6 on: April 02, 2022, 08:04:57 pm »
If you attached the demo project, ppl could see you were talking about ButtonEx, not about Button.

 

TinyPortal © 2005-2018