Discussion:
[Foxgui-users] FXTextField
Julia Dudascik (Contractor)
2017-03-28 21:31:20 UTC
Permalink
Hello

With FXTextField, if I have a really long string, how do I set it so that
when it displays the widget, the cursor is set to the first letter in the
string.

So right now when I create my FXTextField, I set num columns to 50. The
user selects a string that is 250 characters long. I would only like to
display the first 50 characters of this string and the user
can scroll through the textfield to see the other characters. When
FXTextField is displayed, it does not show the begining of the string.
Instead it shows the end of it. The user has to press the home button in
the textfield to get to the start of the string. I would like FXTextField
to always display from the start of the string. How do I do this?

Thanks
Julia
thierry Lorthiois
2017-03-28 21:38:11 UTC
Permalink
With Fox 1.6, I have to inherit FXTextField and customize layout()
function to do what you want :

void ThemeTextField::layout() {
FXTextField::layout();
// Correct Fox left align
if (options&JUSTIFY_LEFT) {
shift = 0;
}
}

And then use JUSTIFY_LEFT option

Regards,

Thierry
Post by Julia Dudascik (Contractor)
Hello
With FXTextField, if I have a really long string, how do I set it so
that when it displays the widget, the cursor is set to the first
letter in the string.
So right now when I create my FXTextField, I set num columns to 50.
The user selects a string that is 250 characters long. I would only
like to display the first 50 characters of this string and the user
can scroll through the textfield to see the other characters. When
FXTextField is displayed, it does not show the begining of the string.
Instead it shows the end of it. The user has to press the home button
in the textfield to get to the start of the string. I would like
FXTextField to always display from the start of the string. How do I
do this?
Thanks
Julia
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Foxgui-users mailing list
https://lists.sourceforge.net/lists/listinfo/foxgui-users
JVZ
2017-03-28 22:00:07 UTC
Permalink
On Tue, 28 Mar 2017 23:38:11 +0200
Post by thierry Lorthiois
With Fox 1.6, I have to inherit FXTextField and customize layout()
void ThemeTextField::layout() {
FXTextField::layout();
// Correct Fox left align
if (options&JUSTIFY_LEFT) {
shift = 0;
}
}
Please explain what you're trying to visually accomplish. Left-justified
text is supposed to keep the left side visible when you resize the control.


-- JVZ


+----------------------------------------------------------------------------+
| Copyright (C) 17:00 03/28/2017 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
thierry Lorthiois
2017-03-28 23:13:22 UTC
Permalink
Hi Jeroen,

I try to have text aligned on the left (even if "size of text" > "size
of control").
- the user can scroll the text
- when the control loose the focus, it should return to default alignement

Not sure, this behaviour is usefull to everybody ?

Regards,

Thierry
Post by JVZ
On Tue, 28 Mar 2017 23:38:11 +0200
Post by thierry Lorthiois
With Fox 1.6, I have to inherit FXTextField and customize layout()
void ThemeTextField::layout() {
FXTextField::layout();
// Correct Fox left align
if (options&JUSTIFY_LEFT) {
shift = 0;
}
}
Please explain what you're trying to visually accomplish. Left-justified
text is supposed to keep the left side visible when you resize the control.
-- JVZ
+----------------------------------------------------------------------------+
| Copyright (C) 17:00 03/28/2017 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
JVZ
2017-03-28 21:51:50 UTC
Permalink
On Tue, 28 Mar 2017 17:31:20 -0400
Post by Julia Dudascik (Contractor)
Hello
With FXTextField, if I have a really long string, how do I set it so that
when it displays the widget, the cursor is set to the first letter in the
string.
So right now when I create my FXTextField, I set num columns to 50. The
user selects a string that is 250 characters long. I would only like to
display the first 50 characters of this string and the user
can scroll through the textfield to see the other characters. When
FXTextField is displayed, it does not show the begining of the string.
Instead it shows the end of it. The user has to press the home button in
the textfield to get to the start of the string. I would like FXTextField
to always display from the start of the string. How do I do this?
Thanks
Julia
The question is if the current behaviour is good or not; maybe it should
not scroll the string to bring the end of the string (where the cursor
went to) into view.

At any rate, for now you could fix it by calling makePositionVisible(0)
on the FXTextField; this should scroll the start of the string back into
view.

The idea is one would typically add new text at the end of a string, so
you probably would want to see the end. However, if you take the standpoint
that the full string is to be replaced, maybe one doesn't care to see the
string anyway.

One could argue selecting the whole string should NOT scroll to bring the
tail end of it into view. I'm open to suggestions on that front....



-- JVZ



+----------------------------------------------------------------------------+
| Copyright (C) 16:40 03/28/2017 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
Julia Dudascik (Contractor)
2017-03-29 18:48:04 UTC
Permalink
Hi

The function makePositionVisible(0) sets the cursor to 1 after position 0.
So it was showing in the textfield from the second character, onward. Is
this the expected behaviour? The user has to press the home button in the
textfield to get it to show from the beginning of the string. So, after I
create my textfield, I send the message ID_CURSOR_HOME to my textfield.
This sets the cursor to the very beginning of the string, which is what I
want.

Thank you.
Julia
Post by JVZ
On Tue, 28 Mar 2017 17:31:20 -0400
Post by Julia Dudascik (Contractor)
Hello
With FXTextField, if I have a really long string, how do I set it so that
when it displays the widget, the cursor is set to the first letter in the
string.
So right now when I create my FXTextField, I set num columns to 50. The
user selects a string that is 250 characters long. I would only like to
display the first 50 characters of this string and the user
can scroll through the textfield to see the other characters. When
FXTextField is displayed, it does not show the begining of the string.
Instead it shows the end of it. The user has to press the home button in
the textfield to get to the start of the string. I would like FXTextField
to always display from the start of the string. How do I do this?
Thanks
Julia
The question is if the current behaviour is good or not; maybe it should
not scroll the string to bring the end of the string (where the cursor
went to) into view.
At any rate, for now you could fix it by calling makePositionVisible(0)
on the FXTextField; this should scroll the start of the string back into
view.
The idea is one would typically add new text at the end of a string, so
you probably would want to see the end. However, if you take the standpoint
that the full string is to be replaced, maybe one doesn't care to see the
string anyway.
One could argue selecting the whole string should NOT scroll to bring the
tail end of it into view. I'm open to suggestions on that front....
-- JVZ
+-----------------------------------------------------------
-----------------+
| Copyright (C) 16:40 03/28/2017 Jeroen van der Zijp. All Rights Reserved. |
+-----------------------------------------------------------
-----------------+
JVZ
2017-03-29 19:19:08 UTC
Permalink
On Wed, 29 Mar 2017 14:48:04 -0400
Post by Julia Dudascik (Contractor)
Hi
The function makePositionVisible(0) sets the cursor to 1 after position 0.
So it was showing in the textfield from the second character, onward. Is
this the expected behaviour? The user has to press the home button in the
textfield to get it to show from the beginning of the string. So, after I
create my textfield, I send the message ID_CURSOR_HOME to my textfield.
This sets the cursor to the very beginning of the string, which is what I
want.
makePositionVisible() works properly, provided its called AFTER the widget
tree is realized and layout has been performed.

To ensure makePositionVisible() has the intended effect, make sure you're
calling it after widget tree is realized and laid out.

In fact, makePositionVisible() does absolutely *nothing* when called prior
to the widget tree being realized!

Hope this information helps finding out what the problem was.



Regards,

-- JVZ




+----------------------------------------------------------------------------+
| Copyright (C) 13:50 03/29/2017 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
Loading...