View Issue Details

IDProjectCategoryView StatusLast Update
0019824LazarusLCLpublic2013-04-29 10:46
ReporterAvishai Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.31 (SVN) 
Target Version1.2.0 
Summary0019824: TLabeledEdit does not support BiDiMode
DescriptionAdding BiDiMode and ParentBiDiMode to TLabeledEdit and TBoundLabel does not completely solve this problem. The Text is displayed correctly and the Edit box works OK, but the Label remains Left-Aligned when BiDiMode:= bdRightToLeft and LabelPosition is lpAbove or lpBelow. Also, when BiDiMode changes, it should call "DoPositionLabel".

I tried making these changes and found a very strange behavior. If LabelSpacing:= 3 (the default) the Label stays Left-Aligned regardless of BiDiMode. But setting LabelSpacing to any other value allows the Label Alignment to be Right-Aligned.
Additional InformationThis is the code change I tried to give BiDiMode functionality. The changes are indicated between "// Avishai's code changes begin here" and "//Avishai's code changes end here".

-----------------

procedure TCustomLabeledEdit.DoPositionLabel;
begin
  if FEditLabel = nil then exit;
  if Parent<>nil then
    Parent.DisableAlign;
  //DebugLn(['TCustomLabeledEdit.DoPositionLabel ']);
  FEditLabel.Parent := Parent;
  FEditLabel.Visible := Visible;
  case FLabelPosition of
    lpAbove:
      begin // Avishai's code changes begin here
        if BiDiMode = bdRightToLeft then begin
          FEditLabel.Anchors:=[akRight,akBottom];
          FEditLabel.AnchorParallel(akRight,0,Self);
          FEditLabel.AnchorToNeighbour(akBottom,FLabelSpacing,Self);
        end else begin
          FEditLabel.Anchors:=[akLeft,akBottom];
          FEditLabel.AnchorParallel(akLeft,0,Self);
          FEditLabel.AnchorToNeighbour(akBottom,FLabelSpacing,Self);
        end;
      end;
    lpBelow:
      begin
        if BiDiMode = bdRightToLeft then begin
          FEditLabel.Anchors:=[akRight,akTop];
          FEditLabel.AnchorParallel(akRight,0,Self);
          FEditLabel.AnchorToNeighbour(akTop,FLabelSpacing,Self);
        end else begin
          FEditLabel.Anchors:=[akLeft,akTop];
          FEditLabel.AnchorParallel(akLeft,0,Self);
          FEditLabel.AnchorToNeighbour(akTop,FLabelSpacing,Self);
        end;
      end; //Avishai's code changes end here
TagsNo tags attached.
Fixed in Revision
LazTarget1.2
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0019303 acknowledged BiDi meta issue 

Activities

Flávio Etrusco

2011-09-15 05:07

developer   ~0051840

Last edited: 2011-09-15 05:29

Ideally, should the side of the label be switched too? (if they can be made to adjust their positions to occupy the same total area as the RTL)

Avishai

2011-09-15 06:45

reporter   ~0051842

Thanks for looking at this. When BiDiMode:= bdRightToLeft the TLabel should be positioned to the Right side of the TEdit. I have attached an image to better explain.

I would like to thank all of the developers with Lazarus and FPC. I think you are amazing. It is easy to complain when things are not right but not so easy fix what is wrong. It is even harder for some to say thank you when some one helps them. Thank you to all of you :)

Flávio Etrusco

2011-09-15 07:05

developer   ~0051843

Mantis doesn't upload the attachment while you add a comment :-/ (If that's what happened)

Let me clarify my question (sorry), so you can clarify your answer ;-)
I saw your code, I see the anchor change when BiDi change.
My question is: beyond your patch, should the BiDi change also invert the label position when the position is lpRight or lpLeft?

2011-09-15 08:29

 

EditLabel.PNG (27,833 bytes)   
EditLabel.PNG (27,833 bytes)   

Avishai

2011-09-15 08:55

reporter   ~0051845

Last edited: 2011-09-15 09:05

"should the BiDi change also invert the label position when the position is lpRight or lpLeft?"

I hope this will explain. If you place 4 TEdits and 4 TLabels on a TPanel to show the four possible Label locations (alAbove, alBelow, alLeft, alRight), changing BiDiMode:= bdRightToLeft should do the same as TPanel.FlipChildren(True). At least this is my opinion. This would be consistent with other Lazarus controls, like TRadioGroup.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Panel1.FlipChildren(True);
  if Panel1.BiDiMode=bdLeftToRight then
    Panel1.BiDiMode:= bdRightToLeft
  else
    Panel1.BiDiMode:= bdLeftToRight;
end;

Avishai

2011-09-24 19:02

reporter   ~0052149

I finally had a chance to look at TLabeledEdit again. If the Parent BiDiMode is bdRightToLeft, the Label now positions correctly. Thank you for your effort. Nice work. :) I did notice though that BiDiMode and ParentBiDiMode are not in the published section, so they can not be set in the property editor. I tried adding these properties but it only effects the TEdit so something more is needed.

samuel herzog

2011-09-24 20:44

developer   ~0052153

Hi Avishai, sorry I did not understand your last comment?

Do you think this problem is solved? So this but-report can be closed?

Flávio Etrusco

2011-09-24 21:32

developer   ~0052155

Good to know, though that was totally coincidental :D
There was a fix in TLabeledEdit for copying'n'pasting it in the designer, and I changed AnchorToNeighbour to AnchorToCompanion, that must have fixed the BiDi.
It seems no developer has looked into this issue yet (or maybe is waiting for a patch from me? :-$ I don't have svn access.), as adding the properties is easy enough.
I started a patch to enhance TLabeledEdit and TButtonEdit behaviors (place/aacount the label/button inside the component area) which would better support BiDi, but I didn't have the time to complete it.

Avishai

2011-09-24 21:37

reporter   ~0052156

I will try to explain. When you place TLabeledEdit on a Form, if the Parent of the component is BiDiMode:= bdLeftToRight but you want the TLabeledEdit to be BiDiMode:= bdRightToLeft, you can not set this in the Property Editor. If you add BiDiMode and ParentBiDiMode to the Published section of TLabeledEdit you can set this at Design-Time. I tried adding this hoping that it would be enough. But setting bdRightToLeft only effected the TEdit. The Label did not reposition and the Caption remained bdLeftToRight (meaning punctuation is misplaced). Some code needs to be added so that the Label knows that is should change BiDiMode and position when the TLabeledEdit BiDiMode changes. Changing BiDiMode in Run-Time is the same. The Edit changes but the Label does not.

Avishai

2011-09-24 21:53

reporter   ~0052157

You can see this by placing a TLabeledEdit and a button on a Form and setting the Label.Caption and TLabeledEdit.Text to "Hello!". Leave TForm.BiDiMode:= bdLeftToRight. In the TButton.OnClick:

procedure TForm1.Button1Click(Sender: TObject);
begin
  LabeledEdit1.BiDiMode:= bdRightToLeft;
end;

Flávio Etrusco

2011-09-25 16:03

developer   ~0052175

Sure, the BiDiMode of the label must be set in TCustomLabeledEdit.DoPositionLabel.
In case you don't know, for now you can change it through LabeledEdit1.EditLabel.BiDiMode.

Avishai

2011-09-25 16:40

reporter   ~0052180

Thank you Mr. Etrusco,

I am aware of setting LabeledEdit1.EditLabel.BiDiMode. I am only trying to help completing the task of making the control fully BiDi aware. I think making Lazarus/FPC strong in Globalization will increase it's popularity. If you have seen my posts, most of them have to do with RightToLeft languages.

Avishai

2011-10-03 20:53

reporter   ~0052468

I finally had a chance to tinker with TLabeledEdit again. If you can find a way to make sure that the EditLabel.BiDiMode always matches TLabeledEdit.BiDiMode, that should fix it.

The next point is more for my education than anything. I noticed that the Owner of the TEditLabel is Self. So I tried LabeledEdit1.Free and saw that the EditLabel was left behind. So I tinkered with it a bit more and made the Owner the TLabeledEdit. Then when I did LabeledEdit1.Free both were Freed, or at least it appeared that way. Is there something wrong with this approach?

Avishai

2012-07-25 08:43

reporter   ~0061230

This issue was fixed some time ago. I think it can be Closed.

Juha Manninen

2013-04-29 10:44

developer   ~0067251

Resolving as requested by reporter.

Issue History

Date Modified Username Field Change
2011-07-27 17:19 Avishai New Issue
2011-07-27 17:19 Avishai Widgetset => Win32/Win64
2011-08-12 12:17 Juha Manninen Relationship added related to 0019303
2011-09-15 05:07 Flávio Etrusco Note Added: 0051840
2011-09-15 05:29 Flávio Etrusco Note Edited: 0051840
2011-09-15 06:45 Avishai Note Added: 0051842
2011-09-15 07:05 Flávio Etrusco Note Added: 0051843
2011-09-15 08:29 Avishai File Added: EditLabel.PNG
2011-09-15 08:55 Avishai Note Added: 0051845
2011-09-15 09:05 Avishai Note Edited: 0051845
2011-09-24 19:02 Avishai Note Added: 0052149
2011-09-24 20:44 samuel herzog Note Added: 0052153
2011-09-24 21:32 Flávio Etrusco Note Added: 0052155
2011-09-24 21:37 Avishai Note Added: 0052156
2011-09-24 21:53 Avishai Note Added: 0052157
2011-09-25 16:03 Flávio Etrusco Note Added: 0052175
2011-09-25 16:40 Avishai Note Added: 0052180
2011-10-03 20:53 Avishai Note Added: 0052468
2011-10-07 15:58 Vincent Snijders LazTarget => 1.2
2011-10-07 15:58 Vincent Snijders Status new => acknowledged
2011-10-07 15:58 Vincent Snijders Target Version => 1.2.0
2012-07-25 08:43 Avishai Note Added: 0061230
2013-04-29 10:44 Juha Manninen Note Added: 0067251
2013-04-29 10:44 Juha Manninen Status acknowledged => resolved
2013-04-29 10:44 Juha Manninen Resolution open => fixed
2013-04-29 10:44 Juha Manninen Assigned To => Juha Manninen
2013-04-29 10:46 Avishai Status resolved => closed