Forum > Designer

Guide Lines Behavior

(1/2) > >>

GerholdtSchnaps:
hi. I'm new here. I came from delphi. And I have a lot of questions...

please consider this situation. The blue line is the guide line. the red line is mine to show the offset. and purple to show how the text is aligned. is it possible to fix this using options, or should I disable recommendations?

majolika:
Hi! I'm new here too. :)
I don't know if I'm right but I think this happens because of different client areas of TButton and TEdit.
If you uncheck AutoSize property of TEdit1 and anchor its bottom to TButton1 bottom you'll see situation like this (1st picture in attach): tops and bottoms aligned but...
Check ClientHieght of both controls in a manner like this and you'll see something like this (2nd picture in attach).


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin  ShowMessage('Button1.ClinetHeight = ' + Button1.ClientHeight.ToString + ', Edit1.ClinetHeght = ' + Edit1.ClientHeight.ToString);end; 
But I have no idea how to fix this.

majolika:
You can dive into a source of TEdit to see why the text inside is aligned like that but it might be a too long journey.

n7800:
I don't quite understand your question. I take it this is a screenshot from Delphi? Lazarus doesn't show guidelines for the text (purple in the screenshot).

If you want the text inside the button and edit to be on the same level, it's unlikely to be possible, since Lazarus is cross-platform. It usually uses native widgets, which depend on the OS, its theme, widget set... They can be anything, and the text position in them cannot be guaranteed.

wp:
In many cases you can achieve almost perfect alignment of the text baseline (within 1 pixel) by anchoring the vertical center of controls using the anchor editor. This is because the text within TLabel, TEdit, TCombobox, TButton, is centered already and because usually all controls have the same font size (i.e. text height).

Suppose you want to have a button, a label and a edit (in this order) in a row and you want to place them vertically such that their caption/text is at the same baseline:

* Drop the three controls on the form (or panel, or whatever...) and position them roughly
* Open the Anchor Editor
* Select the label in the form designer
* In the anchor editor, go to the "Top anchoring" group and select the button control from the combobox. Then click the middle alignment button in the group to center the label with respect to the button. Note that the icon of this button tries to express just this (the other buttons in this group are for vertical anchoring at the top and bottom sides, respectively)
* Repeat with the edit control
* Now all three controls are anchored vertically and centered with respect to the button. If you drag the button vertically to another place, the label and the edit will follow (but this also means that you cannot drag the label and edit vertically any more)
* You can go a step further and anchor also the controls horizontally

Navigation

[0] Message Index

[#] Next page

Go to full version