0

I dropped a TMemo and a regular TStyleBook on a Form. I edited the custom style for the TMemo by adding a TRectangle to background so TMemo now has a different background color, and changed the TMemo.StyleLookup property to the actual StyleName, but at runtime the TMemo can not get focus.

unit Form1;

interface

type
  TForm1 = class(TForm1)
    Memo1: TMemo;
    StyleBook1: TStyleBook;
  end;

var
  Form1: TForm;

implementation

{$R *.fmx}

end.

StyleBook_StyledMemo

What I am missing?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
user2383818
  • 709
  • 1
  • 8
  • 19
  • Make sure HitTest is set to False on the Rectangle – Dave Nottage Nov 10 '19 at 23:33
  • @user2383818 you mean Dave, not me. – Remy Lebeau Nov 11 '19 at 03:41
  • Yes Dave. My mistake. – user2383818 Nov 11 '19 at 11:11
  • @DaveNottage. I did. It is set to False. Same for background, content, etc. I tried also setting a TRectangle as the MemoStyle. This way, the TMemo is focused but the cursor caret is placed over the TRectangle stroke border even if I set the Padding property to any value. This is very frustrating and time consuming, time that I should spent developing my application – user2383818 Nov 11 '19 at 13:37

1 Answers1

0

Turns out that for setting properties to be applied to the background of the tMemo, the original background item must be replaced by a tRectangle and it's StyleName assigned with background. All items inside the original background, must be transferred to the new tRectangle background and the original must be deleted. The Align property of the tRectangle background must be set to Contents and The Align property of the contents item must be set to Client. After that, any property of the new tRectangle background can be set to the desired value and they will be properly displayed at design and run time. Finally yes, the tMemo can be focused!

StyleContainer
...
Memo1Style1
   ...
   background
   ...
...

background above, must be a tRectangle

user2383818
  • 709
  • 1
  • 8
  • 19