Re: FXTextField setLayoutHints

Jeroen van der Zijp <[email protected]>
Newsgroups gmane.comp.lib.fox-toolkit.user
Organization FOX Toolkit
Message-ID <[email protected]>
On Sun, 19 Feb 2023 21:12:26 -0500
"John Selverian" <[email protected]> wrote:

> I want to switch some text fields back and forth between
> TEXTFIELD_REAL and TEXTFIELD_INTEGER.
> 
>  
> 
>  
> 
> I first set them up like this:
> 
>  
> 
>  
> 
> for (int i = 0; i < NUM_ALLOY_ELEMENTS; i++)
> 
> {
> 
>                 _minConc_TF[i] = new
> FXTextField(_alloyingElms_GB[i], 12, this,
> ID_MIN_MAX_TEXT_FIELDS, TEXTFIELD_REAL | TEXTFIELD_LIMITED |
> FRAME_THICK | LAYOUT_CENTER_X);
> 
> }
> 
>  
> 
>  
> 
> Then depending on some other input I try and switch them like
> this:
> 
>  
> 
>  
> 
> _minConc_TF[i]->setLayoutHints(TEXTFIELD_INTEGER |
> TEXTFIELD_LIMITED | FRAME_THICK | LAYOUT_CENTER_X);
> 
>  
> 
>  
> 
> But it does not work. They are still TEXTFIELD_REAL.
> 
>  
> 
> Can I change this on the fly or do I have to delete them and
> recreate them to switch this?

The simplest way might be to use setTextStyle() and getTextStyle()
instead; setLayoutHints() only affects the layout flags (which are
actually interpreted by the FXTextField's parent layout manager).

And yes, several APIs all affect the same single "options" variable
in the widget.  You can set most of them via ctor.  

But when programmatically changing its usually safer to affect only 
one aspect of the widget, such as layout, style, justification, etc.




     -- JVZ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.