the app calls for the user to key in a series of values in a textfield view. she hits the RETURN key or clicks on a button, and the app does its thing. as a courtesy, the app saves the values that were keyed in for next time (the user will tend to reuse them). no need to key them in again. sometimes the user might add some more values. no need to start from the beginning; she only need type in the additions. the entire set of values will be saved automatically. (of course, the user can clear the set and start anew at any time.) on launch the app populates the textfield view with the saved values, if any. if there are none, it just waits for user input.
the app was ported from B4A where it behaved as expected. there is a problem, however when porting the app to B4J to run on a windows pc. please refer to the attached image.
if i set a textfield's text (as described above: assigning it either manually or by reading from a file), the text is highlighted as is visible in the image. not only that, but the cursor is positioned at the start of the first character. if the user starts to type, the entire text is erased. i don't want any of that behavior. by the way, if i set the text in the designer, the same thing happens. so it's consistent from all angles.
how do i avoid the text's being highlighted?
1) i thought about trying to "unrequest" the focus for that view. i don't see how to accomplish that.
2) i tried using a second, tiny dummy textfield view and having it request focus away from the main textfield view. that works, but only if the second textfield is visible (which i don't want; no matter how small you make the dummy view, the user still sees a cursor blinking inexplicably in some random
spot of the screen.)
3) i have noticed that if i simply click on the mouse (while within the textfield view), the highlighting disappears, the text remains, and the mouse magically moves from the first character to 1 character after the current end of the text. that is, of course, exactly what i want to see, but without having to click the mouse. plus it's silly to have to tell the user "please click on mouse to remove highlighting".
so i thought i would try to simulate a mouse click. in B4A i just call a view's "click" sub as if i had clicked on it, but it doesn't seem to be the same thing in B4J. i also tried the jAWTrobot library by calling its mousepress, mouserelease methods one after another, as if clicking. i assumed the standard B4J "MouseClicked" sub for the view would see that, but it doesn't...
4) i tried to massage the textfield's selectionend and selectionstart properties, but couldn't get the right combination of values to have any effect.
thanks in advance for any suggestions.
-go
the app was ported from B4A where it behaved as expected. there is a problem, however when porting the app to B4J to run on a windows pc. please refer to the attached image.
if i set a textfield's text (as described above: assigning it either manually or by reading from a file), the text is highlighted as is visible in the image. not only that, but the cursor is positioned at the start of the first character. if the user starts to type, the entire text is erased. i don't want any of that behavior. by the way, if i set the text in the designer, the same thing happens. so it's consistent from all angles.
how do i avoid the text's being highlighted?
1) i thought about trying to "unrequest" the focus for that view. i don't see how to accomplish that.
2) i tried using a second, tiny dummy textfield view and having it request focus away from the main textfield view. that works, but only if the second textfield is visible (which i don't want; no matter how small you make the dummy view, the user still sees a cursor blinking inexplicably in some random
spot of the screen.)
3) i have noticed that if i simply click on the mouse (while within the textfield view), the highlighting disappears, the text remains, and the mouse magically moves from the first character to 1 character after the current end of the text. that is, of course, exactly what i want to see, but without having to click the mouse. plus it's silly to have to tell the user "please click on mouse to remove highlighting".
so i thought i would try to simulate a mouse click. in B4A i just call a view's "click" sub as if i had clicked on it, but it doesn't seem to be the same thing in B4J. i also tried the jAWTrobot library by calling its mousepress, mouserelease methods one after another, as if clicking. i assumed the standard B4J "MouseClicked" sub for the view would see that, but it doesn't...
4) i tried to massage the textfield's selectionend and selectionstart properties, but couldn't get the right combination of values to have any effect.
thanks in advance for any suggestions.
-go