B4J Question Textfield with cr lf crlf

madru

Active Member
Licensed User
Longtime User
Hi,

any possibility to preserve cr / lf / crlf in a Textfield after a user copies text to that field?

THX

M
 

stevel05

Expert
Licensed User
Longtime User
Textfield only holds a single line of text, you would need to use TextArea.
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
sure, the Textfield can only hold one line, no question about that fact

we did in 2017 a Building control App for a client.... on the MainForm we have a textfield for manual input of information, this field got enabled in the case of an security alert in the building triggered by an network message. They could insert text up to 20 chars. Now they came back and asked for full text input (fair enough). The problem is that we cannot change the layout anymore. We implemented some workaround like having the textfield for short inputs, double click on that one will open a form with an TextArea. Closing the form will copy the TextArea into the textfield, in that case we will loose cr/lf/crlf. Trying to use a TextArea instead of the text field fails because it is not possible to have a TextArea with a hight of 20. The idea was now to convert the cr/lf/crlf to a displayable special character and display one (long) line in the Textfield......

that's the problem, any ideas how to solve this ?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
You could add an image/button next to the TextFiled (or a different input event along the double tap to the TextField itself) which will show a form/dialog/panel containing the TextArea aand its multi-line text. In this case the TextField will contain the first part of the message and an indication for "more text".
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
how about using textfield + textarea (visible=false).
if textfield get focus u make textarea visible at top of the layout and set his input focus.
after lost focus u hide the textarea and copy the text into the single line textbox.
or using a label + button and show/hide the textarea for input.
 
Upvote 0
Top