View Issue Details

IDProjectCategoryView StatusLast Update
0037362LazarusIDEpublic2020-07-23 19:50
ReporterPaul Long Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformLinuxOSKubuntu Manjaro KDENeon 
Product Version2.0.10 
Summary0037362: Changing Form Name Produces odd behavior in Title bar when running form
DescriptionChanging Form Name Produces odd behavior in Title bar when running form. If you change the caption of the form and run the form, an opening angle bracket, a number, and a closing angle bracket are appended to the end of the title. [See Attachments]
Steps To ReproduceChange name of form and run.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

Paul Long

2020-07-15 16:48

reporter  

Edit Mode.png (15,342 bytes)   
Edit Mode.png (15,342 bytes)   
Run.png (16,284 bytes)   
Run.png (16,284 bytes)   

Zeljan Rikalo

2020-07-15 16:51

developer   ~0124049

It's about x11 handling of forms, not about gtk2. IMO - not bug.

Bart Broersma

2020-07-15 18:28

developer   ~0124055

I think Zeljan is right.

Paul Long

2020-07-22 16:00

reporter   ~0124231

Zeljan and Bart

So what you guys are saying is "you're on your own KDE users, it's not our problem". Maybe a simple fix would be to put a trim around the form property.

I found that if you enter the form caption programatically, the problem is nonexistent. Are you guys actually Lazarus programmers? If you are you just alienated

a whole group of linux users with your laxidasical comments.

Juha Manninen

2020-07-22 16:31

developer   ~0124232

This is not about changing a form's name. You get the same behavior with the default "Form1" name.
It is also not specific to KDE. IIRC it happens with other desktops / Window Managers, too. I use KDE myself though.

> Maybe a simple fix would be to put a trim around the form property.
What do you mean by that?

The extra <2> in a form's caption is not a problem because it happens only when you develop your application. Then the Window Manager (or X11) wants to differentiate the design and run time forms.
When the application is ready and you run it without Lazarus, the caption is correct. No problem.

> a whole group of linux users with your laxidasical comments.
You mean lackadaisical? I am a Linux user but the issue has not bothered me. If it bothers somebody enough, he can always fix it and provide a patch. This is a voluntary FOSS project.
One possible solution is to temporarily append a " [design]" suffix to the caption of design time form just before running the form. Or something ...

Paul Long

2020-07-22 19:53

reporter   ~0124235

Juha

Thank you for your response and spellcheck. I suck at spelling.
Are you saying that <2> won't appear in the final Compilation?
I was only making a suggestion about trimming the Caption. Something like trim(form.caption).
I admit I don't understand the inner workings of the Lazarus application but I wish I was Knowledgeable
enough to contribute to the project programmatically.
I think your message ran out of space at the end. You were saying something about appending [design]
to the caption. Can you elaborate? I'm really interested in what you have to offer up as advice.
Thanks again, Paul

Paul Long

2020-07-22 20:02

reporter   ~0124236

Zeljan and Bart

I apologize if I came across sounding too abrupt. Your answers made a lot of sense and I appreciate your input.

Thanks, Paul

Bart Broersma

2020-07-22 21:46

developer   ~0124237

Please close.

Juha Manninen

2020-07-22 21:54

developer   ~0124239

> Are you saying that <2> won't appear in the final Compilation?
It has nothing to do with compilation or LCL code. It is the way a Window Manager (KWin) differentiates 2 GUI windows that have identical captions. You get the same effect by starting two empty Kate text editors.
Or maybe X11 does it instead of Window Manager, not sure.

> Something like trim(form.caption).
That would have no effect obviously.

> I wish I was Knowledgeable enough to contribute to the project programmatically.
Browse and jump in the code and learn it. Debug it line by line to understand more.
Actually nobody knows all the code. It is a constant searching and learning process.

> You were saying something about appending [design] to the caption.
It was just one quick idea. Now the run-time form is started with the same caption as the design-time form. Changing one of them would prevent Window Manager doing its tricks.

BTW, the form's title bar shows either Name or Caption. By default the Caption is a copy of the Name but you can change it freely.

Paul Long

2020-07-23 13:19

reporter   ~0124266

Last edited: 2020-07-23 13:21

View 3 revisions

I still don't get how you can enter the caption programmatically and works fine but when you enter it through the properties window it gives this erroneous result.

procedure TForm1.FormCreate(Sender: TObject);
begin
  form1.caption := 'My new form name';
end;

This works fine. Very Strange.

Well thanks for your feedback guys, I appreciate it so much.

wp

2020-07-23 14:26

developer   ~0124270

Grrrr.... I don't know how often I wrote never to use the form variable in the class code... This is the correct way:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption := 'My new form name'; // <---- NO "Form1" HERE !!!!
end;

Paul Long

2020-07-23 15:24

reporter   ~0124273

Last edited: 2020-07-23 15:25

View 2 revisions

wp

Thanks for the tip. It works great.

I'm new to Pascal and Lazarus.

Can you explain why you don't use form variables in class code?

What is the downside?

wp

2020-07-23 18:23

developer   ~0124280

Last edited: 2020-07-23 18:23

View 2 revisions

Using the form variable inside the form class code has the effect that the code only works when the instance of TForm1 is named exactly like that, Form1. But when you rename it to "Form2"? There is no "Form1" any more, and your program will crash. Or, when Form1 has been created nevertheless, and you create another instance Form2, then Form2 will change the caption of Form1, instead of its own.

When I wrote "Caption := 'My new name'" then this "Caption" refers to the caption of the current instance of TForm1. You can use "self" instead of "Form1" if you want to emphasize that you mean the Captio of the current TForm1 instance.

procedure TForm1.FormCreate(Sender: TObject);
begin
  Self.Caption := 'My new form name';
end;

There is no downside.

But please ask such questions in the forum. The bug tracker is not the correct place for them.

Paul Long

2020-07-23 19:48

reporter   ~0124284

Thanks wp.

Paul Long

2020-07-23 19:50

reporter   ~0124285

The issue was explained to my satisfaction.

Issue History

Date Modified Username Field Change
2020-07-15 16:48 Paul Long New Issue
2020-07-15 16:48 Paul Long File Added: Edit Mode.png
2020-07-15 16:48 Paul Long File Added: Run.png
2020-07-15 16:51 Zeljan Rikalo Note Added: 0124049
2020-07-15 18:28 Bart Broersma Note Added: 0124055
2020-07-22 16:00 Paul Long Note Added: 0124231
2020-07-22 16:31 Juha Manninen Note Added: 0124232
2020-07-22 19:53 Paul Long Note Added: 0124235
2020-07-22 20:02 Paul Long Note Added: 0124236
2020-07-22 21:46 Bart Broersma Assigned To => Bart Broersma
2020-07-22 21:46 Bart Broersma Status new => resolved
2020-07-22 21:46 Bart Broersma Resolution open => no change required
2020-07-22 21:46 Bart Broersma LazTarget => -
2020-07-22 21:46 Bart Broersma Widgetset GTK 2 => GTK 2
2020-07-22 21:46 Bart Broersma Note Added: 0124237
2020-07-22 21:54 Juha Manninen Note Added: 0124239
2020-07-23 13:19 Paul Long Note Added: 0124266
2020-07-23 13:20 Paul Long Note Edited: 0124266 View Revisions
2020-07-23 13:21 Paul Long Note Edited: 0124266 View Revisions
2020-07-23 14:26 wp Note Added: 0124270
2020-07-23 15:24 Paul Long Note Added: 0124273
2020-07-23 15:25 Paul Long Note Edited: 0124273 View Revisions
2020-07-23 18:23 wp Note Added: 0124280
2020-07-23 18:23 wp Note Edited: 0124280 View Revisions
2020-07-23 19:48 Paul Long Note Added: 0124284
2020-07-23 19:50 Paul Long Status resolved => closed
2020-07-23 19:50 Paul Long Note Added: 0124285