(SOLVED) Text overflow.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
(SOLVED) Text overflow.
Hi, so I looked around and didn’t find anything that can help me… so the problem is that I have an entry text field, and I would like that instead of the text overflowing it will get smaller(like the Microsoft calculator on Win 10.) I know how to make text smaller, but I don’t know how to detect if the text has “touched” or overflowed the border of the text field… thanks for your help, it is very much appreciated 
Last edited by AGC studios on Tue Jun 09, 2020 10:45 am, edited 1 time in total.
Re: Text overflow.
Hi,
If i understand you correctly, the formattedWidth should be useful in this case
Best regards
Jean-Marc
If i understand you correctly, the formattedWidth should be useful in this case
Best regards
Jean-Marc
https://alternatic.ch
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
Thanks, I will look into it. 

Re: Text overflow.
Jean-Marc is certainly on the right track.
But is it that you want the textSize to diminish after each entry, so that the new text "fits" into the field? That would get out of hand rather quickly, no? You would want to do something like (untested):
This should diminish the textSize after each new character entry that exceeds the width of the field. But I do not think this a good idea.
Craig
But is it that you want the textSize to diminish after each entry, so that the new text "fits" into the field? That would get out of hand rather quickly, no? You would want to do something like (untested):
Code: Select all
on textchanged
if the formattedWidth of me > the width of me then set the texSize of me to (the textSize of me - 1)
end textchanged
Craig
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
Yes, I looked into it and it worked! THANK YOU!
If anyone is interested in the code:
If anyone is interested in the code:
Code: Select all
on putTextIntoField
if (the formattedWidth of field "textAreaField" + 30) > the width of field "textAreaField" ---the + 30 was because the text would somtimes overflow half(you would only see half of the last char)
then
set the textSize of field "textAreaField" to takeTextSizeDown()
end if
end putTextIntoField
function takeTextSizeDown
put the textSize of field "textAreaField" into tTextSize
put the number of chars of field "textAreaField" into tTextCharNum
return tTextSize - (tTextSize / tTextCharNum) --- this way the size of the font is proportionate to the amount of text
end takeTextSizeDown
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
Yes, I am now looking for a way to get the text to break(sorry about the wrong wording, I don't exactly know how to phrase it... the "enter") Not much luck...That would get out of hand rather quickly, no?
Ps. sorry if this wasn't clear, and thanks for answering

-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
So, I have a new problem...
I'm trying to get a contact number using
But I cannot seem to be able to get the phone number but I can get the name... I looked at every thread and none of them seemed to have an answer... I hope they fixed it... (running LC 9.6 DP 4) (Android 9.0 Pie)

here's my code:
this is for the first name
I'm trying to get a contact number using
Code: Select all
mobileGetContactData
Code: Select all
mobilePickData


here's my code:
Code: Select all
on mouseUp
mobilePickContact
put the result into tID
put mobileGetContactData (tID) into tData
answer tData[phone]["mobile"] -- I also tried answer tData["mobile"]
end mouseUp
Code: Select all
on mouseUp
mobilePickContact
put the result into tID
put mobileGetContactData (tID) into tData
answer tData ["firstname"]
end mouseUp
Re: Text overflow.
Please one problem by post. This make search easier and Klaus gladSo, I have a new problem...
Best
Jean-Marc
https://alternatic.ch
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
Ok, thought it might be better this way... fewer threads... ill move it.
Re: Text overflow.
Do you mean "wrap", that is, automatically display a new line below the original for the newly added text? This is likely the best way, unless something in your app cannot support it. This is what the "dontWrap" property is for.I am now looking for a way to get the text to break
The original idea, to reduce the textSize when you ran out of room, might be acceptable for one or two characters, but probably not for more than that. And it really goes against good practice.
So what are you really trying to achieve?
Craig
-
- Posts: 21
- Joined: Thu Apr 23, 2020 1:49 pm
Re: Text overflow.
Hi, yes so my code goes something like this:
If the text is too big and the text size is above 35 then it will make the text smaller.
If it is below 35 then it will add a "space" and the field will wrap.
and I only let a max. of 20 char.
Anyway, this part works(I don't know how to add the "solved" to the title.) my problem now is the contacts but that is in another thread.
Thank you everyone that answered.
If the text is too big and the text size is above 35 then it will make the text smaller.
If it is below 35 then it will add a "space" and the field will wrap.
and I only let a max. of 20 char.
Anyway, this part works(I don't know how to add the "solved" to the title.) my problem now is the contacts but that is in another thread.
Thank you everyone that answered.
Re: Text overflow. :Solved
To put 'Solved' on the title thread is no trick at all, you simply go to your first post, click on the Edit icon (the pencil), and in the 'Subject' box, append ": Solved" to it, like so -
