Text Area alignment change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 12:04 AM
How to change the alignment of textarea from the default style set in touchgfx designer?
In touchgfx designer(Version:4.21.3) I have set to Left alignment. I use this textarea for multiple purposes, for few I need to set to Left alignment and for few I need to set to Right alignment. I tried using ' textArea.setTextAlignment(TEXT_ALIGNMENT_RIGHT);' but it says set alignment is not a member.
Solved! Go to Solution.
- Labels:
-
TouchGFX
-
TouchGFX Designer
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 6:42 AM - edited ‎2024-07-08 11:38 AM
Hi @BhavyaSri
I use TextAreaWithOneWildcard
// T_ALIGN_LEFT, T_ALIGN_CENTER, T_ALIGN_RIGHT Ids text is "<>" with different alignment
// T_TEXT_MULTIALIGN holds the text to dispaly and alignment does not matter
TextAreaWithOneWildcard::setTypedText ( touchgfx::TypedText ( T_ALIGN_CENTER ) );
TextAreaWithOneWildcard::setWildcard ( touchgfx::TypedText ( T_TEXT_MULTIALIGN ).getText () );
TextAreaWithOneWildcard::invalidate ();
Example:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 6:19 AM
Hello @BhavyaSri ,
I have not seen a method called "setTextAlignment' in the textArea API.
You could try the method resizeToCurrentTextWithAlignment().
I think you should set the alignment directly from Designer instead of code.
If this comment solves your problem, I invite you to select it as "best answer".
Regards,
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 6:27 AM
Thanks for your reply!
I cannot use from designer as I use Same textarea for multiple applications. Some of them need it to be right justified and some of them need it to be Left Justified. I have default set it as Left justified in designer, however for some cases I want to change that to Right justified via code.
Regards,
Bhavya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 6:42 AM - edited ‎2024-07-08 11:38 AM
Hi @BhavyaSri
I use TextAreaWithOneWildcard
// T_ALIGN_LEFT, T_ALIGN_CENTER, T_ALIGN_RIGHT Ids text is "<>" with different alignment
// T_TEXT_MULTIALIGN holds the text to dispaly and alignment does not matter
TextAreaWithOneWildcard::setTypedText ( touchgfx::TypedText ( T_ALIGN_CENTER ) );
TextAreaWithOneWildcard::setWildcard ( touchgfx::TypedText ( T_TEXT_MULTIALIGN ).getText () );
TextAreaWithOneWildcard::invalidate ();
Example:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 7:56 AM - edited ‎2024-07-08 8:49 AM
Attached is Gfx project with extension .pdf - rename it to .zip. Forum does not allow me to attach file with .zip. Strange as I see .zip files shared here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 7:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 8:04 AM
Hi @ferro ,
I'm not able to see .pdf also. I'm able to see only image.
Also, just to add more details to my query:
1. I used textArea1 text field and enabled it as WildCard Buffer is designer.
2. I use 'Unicode::strncpy(textArea1Buffer,textfieldval, TEXTAREA1_SIZE);' in code and this 'textfieldval' will be changed based on microcontroller output.
Please let me know if additional details are required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 8:37 AM
Hello @ferro ,
The ".zip" extension is not supported. Most people use the ".7z" extension to share their files.
Regards,
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 8:38 AM
One simple fix would be to have 2 textAreas. one aligned left and one aligned right and just show the one you need at the time.
But Ferro's solution might be better and cleaner.
Regards,
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-08 8:42 AM
Thanks @GaetanGodart , I see. I saw shared .zip on 'share your widget' thread but that was 2022, it's changed since then.
