ThisGuy
ThisGuy

Reputation: 1415

Text Prompt Delphi XE7

Before I file a QC report to Embacadero, I wanted to know if there is something simple I am overlooking in regards to TEdit's and setting the 'TextPrompt' property.

Whenever trying to set TextPrompt of any TEdit, the Prompt does not show. Am I missing a step or is there a simple work around to this bug that anyone knows of currently?

Delphi XE7 for iOS ( FMX )

Upvotes: 4

Views: 3028

Answers (2)

TysonStephen
TysonStephen

Reputation: 21

You need to use the stylebook to get this to work correctly.

Sample :

  • Create a new multi-device application
  • Add TStylebook component.
  • Set the form stylebook property to Stylebook1
  • add a TEdit

I'll stop here for a second. One would think that because TEdit contains a property called "Text Prompt" that this would be a no brainer, but adding text to this property does not work, why.... No idea. Anyhow.....

  • Right click on the TEdit component and at the bottom, click "Edit custom style"

This will bring up the stylebook1 container.

  • On the structure view, Expand the "edit1style1 : TLayout"
  • Select "Prompt : TLabel"
  • Change the "text" property to whatever you want the prompt to be.
  • Select "apply and close" on the stylebook container

That's it, you will see the text prompt in the tedit control, and when run on multi-platforms it works as expected.

Upvotes: 1

FMXExpress
FMXExpress

Reputation: 1276

You can also just stick a TLabel inside of your TEdit and align it to Content or Client. Set it's HitTest property to false. In the onChange event show it or hide it based on if the Text property is blank. TextPrompt had issues in previous versions too so I used this workaround instead.

Upvotes: 8

Related Questions