Recent

Author Topic: All new components on a form will be Parentfont?  (Read 696 times)

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 328
  • Love my Wife, My Kids and Lazarus/Freepascal.
All new components on a form will be Parentfont?
« on: October 25, 2020, 09:53:08 am »
After I set a Button to font  Segoi ui 26,  all new component that is added to the form
will be ParentFont true, even if it is not set to true  and the object is set to false!!!

Bug that enabl all to parentfont true?
Rob

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: All new components on a form will be Parentfont?
« Reply #1 on: October 25, 2020, 11:31:58 am »
That's the way things work. Suppose you have a container control, a GroupBox for example. When you change the font of the GroupBox it no longer has the font of its own parent (the form), and thus the GroupBox's ParentFont goes to false. When you now add further controls to the GroupBox they inherit the font of the panel because their ParentFont is true by default.

If you do not want the children of the GroupBox to get the font of the group box you must add another container control to the groupbox, and change its Font back to default (this automatically sets its ParentFont to false), before you begin adding the new controls to the new container.

I am not sure if I understand your description correctly. You changed the font of a button, and then suddenly the font of other controls on the form had that same font? In this case you must have changed the font of the form, too. Otherwise I cannot explain such an observation.

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 328
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: All new components on a form will be Parentfont?
« Reply #2 on: October 25, 2020, 01:42:26 pm »
Excuse me for my shy English.

I put a button on a form. Then I changed the fontsize to 26 and the color to red.

Then i put a Radiogroup on the form. Then I add a radiobutton inside the radiogroup and the radiobutton suddenly have the
same size as the button have. fontsize 26. I never seen this behavior before when designingen with Lazarus!

So i resizee the radiobutton to fontsize 9 and the radibutton were ok.

Then i add a new radiobutton in the radiogroup and it also have the same fontsize 26 as the button on the form!
Resize it too to fit the radiogroupbox.

Then I add a Listbox on the form and the items have also fontsize 26! same as the button!
The listbox wouldn't show the items i added either, if i don't click in the box.

I haden't have this problems with a Lazarus form before, and i have used Lazarus in maybe 10 years now or more.
/Bob

Lazarus 2.0.10 r63526 FPC 3.2.0 x86_64-win64-win32/win64
Rob

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: All new components on a form will be Parentfont?
« Reply #3 on: October 25, 2020, 03:42:17 pm »
I put a button on a form. Then I changed the fontsize to 26 and the color to red.
Are you sure that you had selected the button when you changed the font. If the button was not selected then you had changed the font of the form instead, and via ParentFont this would propagate on all controls already added or added later.

I am attaching a project where I tried to follow your description: I added a button, changed its font size to 26 (and tried to change its color - but this is not possible on Windows due to widgetset restrictions -- I don't understand how you could...). Then added a groupbox and a radiobutton as child of the groupbox. --> All fonts are as expected.

Please study this example and try to find out what you did differently.

 

TinyPortal © 2005-2018