Recent

Author Topic: How do you keep trace of code set by object inspector ?  (Read 1211 times)

Paolo

  • Hero Member
  • *****
  • Posts: 639
How do you keep trace of code set by object inspector ?
« on: October 11, 2025, 11:59:01 am »
Hello,

I am working on new application and copy-paste a lot of code form a previous one. But at run time I see different behavior (specifically on the TTreeView component)

I did not see any difference in code going line-by-line…
But after a while I remembered a specific settings in the object inspector : “Treeview->Options->tvoThemeDraw = false”.

Now the question : how to compare code “including” settings done in the object inspector ? in my case to allow duplicating all the settings in the new app ?

Regards.

cdbc

  • Hero Member
  • *****
  • Posts: 2477
    • http://www.cdbc.dk
Re: How do you keep trace of code set by object inspector ?
« Reply #1 on: October 11, 2025, 12:28:24 pm »
Hi
Do a 'diff' on both *.lfm files, that'll tell you the differences the OI has made...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6 -> FPC 3.2.2 -> Lazarus 4.0 up until Jan 2025 from then on it's both above &: KDE6/QT6 -> FPC 3.3.1 -> Lazarus 4.99

Handoko

  • Hero Member
  • *****
  • Posts: 5496
  • My goal: build my own game engine using Lazarus
Re: How do you keep trace of code set by object inspector ?
« Reply #2 on: October 11, 2025, 12:48:34 pm »

wp

  • Hero Member
  • *****
  • Posts: 13228
Re: How do you keep trace of code set by object inspector ?
« Reply #3 on: October 11, 2025, 02:10:53 pm »
Hi
Do a 'diff' on both *.lfm files, that'll tell you the differences the OI has made...
Unfortunately the lfm files are polluted by tons of changes of little interest: When the size of the form changes the change is propagated to aligned or manybe anchored controls. And each new Width and Height is written to the lfm burying the change you are interested in...

440bx

  • Hero Member
  • *****
  • Posts: 5822
Re: How do you keep trace of code set by object inspector ?
« Reply #4 on: October 11, 2025, 02:20:02 pm »
Unfortunately the lfm files are polluted by tons of changes of little interest: When the size of the form changes the change is propagated to aligned or manybe anchored controls. And each new Width and Height is written to the lfm burying the change you are interested in...
This is a question arising out of pure curiosity...

Do you believe it would be possible to create a "smart" .lfm compare tool that could compensate/manage those tiny changes that are not of interest and highlight genuinely important changes ? (maybe something configurable to tell it to ignore specific characteristics.)

FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

wp

  • Hero Member
  • *****
  • Posts: 13228
Re: How do you keep trace of code set by object inspector ?
« Reply #5 on: October 11, 2025, 03:29:57 pm »
I think it would help a lot if there were a possibility to ignore changes of "Width", "Height", "ClientWidth", "Clientheight", "Left", "Top" properties. For "practicing", there is a diff tool coming with Lazarus ("Tools" > "Compare files..."), but I don't find its sources ATM - an extended version of it (including side-by-side comparison) is at https://github.com/DomingoGP/lazIdeDiffCompareFiles.

jcmontherock

  • Sr. Member
  • ****
  • Posts: 316
Re: How do you keep trace of code set by object inspector ?
« Reply #6 on: October 11, 2025, 03:38:57 pm »
I keep the setting by default and set the changes manually of each parameter in Form.Create procedure.
Windows 11 UTF8-64 - Lazarus 4.2-64 - FPC 3.2.2

Hartmut

  • Hero Member
  • *****
  • Posts: 1012
Re: How do you keep trace of code set by object inspector ?
« Reply #7 on: October 11, 2025, 03:39:29 pm »
Hello Paolo,

when I started with Lazarus I found it great, that I could do all settings in object inspector. But after some time I realized a couple of disadvantages doing so (like you did now) and stopped this and since then I do (nearly) all settings in code. The disadvantages were (of course this is a personal view):

a) to see which properties I changed and what values I used:
In code I use 1 procedure per Form which sets all properties of all it's Controls, which need changes from defaults, always called 'setAllPropertiesFormXY'. There I can see on 1 view all what I changed from the defaults. For me this is the best overview. In the OI I had to walk through all Controls one by one and for each Control I had to do a lot of scrolling to see the same. The LFM-file contains much more lines than only my changed properties, which is the opposite of a short overview.

b) comments:
In code I can add comments to each setting wherever I think it's useful. E.g. that 'WordWrap' of a TLabel only works if 'AutoSize' is True. Or that enum 'x' for a property did not work because ... and enum 'y' did not work on Linux, and because of this I choosed enum 'z'. Or that setting a color to a TButton does work on Linux, but not on Windows (and what the alternatives are there). In sum these comments make my life much easier for future projects.

c) copy/paste for other projects:
As you did now, I often copy/paste code fragments from an older project to a newer project. Because I have all changed properties in code, I can easily copy them too - including their comments - and adapt them if needed. This makes my life much easier especially for Controls with many properties to set as e.g. a TStringGrid.

d) searching:
When I want to search, where I have changed a certain property, for me normally it's easier to search for this property with my existing search-tool for all of my sources, than to search all existing LFM-files.

Because of this I use the OI for new projects always only to set:
 - the varname of a Control
 - it's position (needed also for the Designer)
 - it's caption (needed also for the Designer)
 - and to set all Events (because they are visible in code).

Exception: for a quick test of course the OI is very comfortable and to explore / play with a completely unknown Control :-)

Paolo

  • Hero Member
  • *****
  • Posts: 639
Re: How do you keep trace of code set by object inspector ?
« Reply #8 on: October 11, 2025, 04:24:20 pm »
Thanks to all.

Me too thought to set all not default values in the code.

Going in deep in a large app with many controls by comparing lfm contents seems not easy...

It could be reasonable/possible think to an add-on in the IDE that creates a text file with "only" not default values of all the object in the OI ? in this case exporting such "report" file both from original app and from new copied app the comparison should be easier (and also useful for "documentation" purpose).

regards.


LV

  • Sr. Member
  • ****
  • Posts: 360
Re: How do you keep trace of code set by object inspector ?
« Reply #9 on: October 11, 2025, 04:43:23 pm »
in my case to allow duplicating all the settings in the new app ?

In Lazarus, this is easy. Copy a component or group of components from one project to another. The settings you made in the object inspector are preserved. 👌

Paolo

  • Hero Member
  • *****
  • Posts: 639
Re: How do you keep trace of code set by object inspector ?
« Reply #10 on: October 11, 2025, 04:48:21 pm »
@LV good point for my case.

thanks.

PS: however the general question to keep trace/document changes made in OI is still there.

Hartmut

  • Hero Member
  • *****
  • Posts: 1012
Re: How do you keep trace of code set by object inspector ?
« Reply #11 on: October 11, 2025, 04:56:41 pm »
in my case to allow duplicating all the settings in the new app ?

In Lazarus, this is easy. Copy a component or group of components from one project to another. The settings you made in the object inspector are preserved.
Please how can I "Copy a component or group of components from one project to another"? Or do you mean "manually" by manipulation of the LFM-file?

Paolo

  • Hero Member
  • *****
  • Posts: 639
Re: How do you keep trace of code set by object inspector ?
« Reply #12 on: October 11, 2025, 05:02:49 pm »
click on the component to select it, then right mouse button and select copy

wp

  • Hero Member
  • *****
  • Posts: 13228
Re: How do you keep trace of code set by object inspector ?
« Reply #13 on: October 11, 2025, 05:04:48 pm »
Copy the component to the clipboard. Go the receiving form and paste from the clipboard. Works also when the copied component is the container of several subcontrols - they will be copied as well. However, you do not copy event handlers this way.

Hartmut

  • Hero Member
  • *****
  • Posts: 1012
Re: How do you keep trace of code set by object inspector ?
« Reply #14 on: October 11, 2025, 05:21:45 pm »
click on the component to select it, then right mouse button and select copy

Copy the component to the clipboard. Go the receiving form and paste from the clipboard. Works also when the copied component is the container of several subcontrols - they will be copied as well. However, you do not copy event handlers this way.

Great. I think I have "seen" this popupmenu in the past, but I was not "aware" of that feature. Thanks.

 

TinyPortal © 2005-2018