Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

Parent Controls And TEdit TextPrompt Workaround In Delphi XE7 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE7 Firemonkey TEdit TextPrompt Workaround Fix | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSThere is an issue with the TextPrompt property of TEdit in Delphi XE7 Firemonkey where it does not show up. According to the Quality Central report on the problem it has already been fixed and will probably be part the next update. However, this is an opportunity to highlight just how powerful Firemonkey can be by allowing any control to be parented by any other control. Don’t get hung up thinking that there is only one way to solve a problem. In traditional VCL only the TPanel or third party components allowed a component to be inside of another component (with some exceptions). With Firemonkey you can take a button or a label and put it inside of another button or label or edit control. With this in mind if you would like to build your own TextPrompt functionality you can simply take a TLabel and place it inside of your TEdit control. Change the HitTest property of the TLabel to False so that it allows all mouse or tap events to pass through it to the TEdit control. Set the Align property of the TLabel to Content or Client. Content fills the parent control regardless of any other child controls and Client fills the parent control but makes space for other aligned child controls. Next add code into the OnChange/OnKeyUp event (and/or the OnTyping event) which shows or hides the TLabel based on if TEdit is empty or not. If you want to get fancy you could put a semi transparency on the TLabel with the Opacity property or by changing it’s color to a lighter grey color. This parenting functionality of Firemonkey controls works cross platform on Android, IOS, Windows, and OSX. I recommend using this TLabel method instead of the TextPrompt property in Delphi XE5 and Delphi XE6 as well.

Head over and check out an article on the Embarcadero docwiki about arranging and parenting controls in Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging


Unleashing Creativity With Song Writer AI: A Deep Dive


How To Build Stable Diffusion Text To Image Prompts


FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

1 Comment

Leave a Reply