Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firemonkey TEdit height

I'm using Delphi Seattle and my application is for Windows Desktop.

I'm trying to change the font size of a TEdit. Consequently the height was also modified. At design time everything works well, but when I run my application TEdit ignores the height modification and the text is cut.

I've tried to find FixedHeight as suggested here, but I couldn't find this property.

Is it possible to change TEdit Heigth?

like image 926
Daniel Grillo Avatar asked Apr 07 '16 13:04

Daniel Grillo


2 Answers

This can be solved by overriding the control’s AdjustFixedSize method. As explained by @chrisrolliston, Removing a FMX control’s size restrictions and exemplified here:

unit Unit4;
interface
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit, MyTEdit;

type
  TForm4 = class(TForm)
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
  end;

var
  Form4: TForm4;

implementation

{$R *.fmx}

procedure TForm4.FormCreate(Sender: TObject);
begin
  Edit1.Height := 60;
end;

end.

unit MyTEdit;
interface
uses
  FMX.Edit, FMX.Controls;

type
  TEdit = class(FMX.Edit.TEdit)
  protected
    procedure AdjustFixedSize(const Ref: TControl); override;
  end;

implementation
uses
  FMX.Types;

procedure TEdit.AdjustFixedSize(const Ref: TControl);
begin
  SetAdjustType(TAdjustType.None);
end;

end.
like image 106
LU RD Avatar answered Sep 25 '22 22:09

LU RD


If your're using styles in StyleBook:

  1. First check style name in EditBox - look at StyleLookup of TEdit in Object inspector. If it's empty, that means default editstyle for Editbox. You should search this name in styles.
  2. Open current style, select you platform, find editstyle in a list of styles.
  3. Change FixedHeight to 0. Also you can set Align = None to reset align height.
like image 29
alitrun Avatar answered Sep 24 '22 22:09

alitrun