B4J Question [SOLVED] TextField : need the text to auto scroll to make the last part visible

Cableguy

Expert
Licensed User
Longtime User
Hi guys...

I have a TextField that will hold a path (several textfields to do the same), this presents no problem, except that only the initial part of the path is visible (Leftmost) and if the path is bigger that the textfield width, I have no idea of what the rest of the path looks like.
How can I force the textfield to show the rightmost part of the path without having to trim it?
 

stevel05

Expert
Licensed User
Longtime User
The only way I could find to display the tail of the text is a bit of a hack, I couldn't find any methods to help. You could easily wrap it into a customview. The full text is stored in the textfields tag.
 

Attachments

  • TFDisplay.zip
    2.3 KB · Views: 223
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I found a few links about text alignment, using CSS, but trying them did not have the expected results.
The tooltip hack is quite a good idea
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
You can bind the textfield.text value to the tooltip.text so they are always in sync without the need to change the tooltip text in textfield.textchanged event.
Using javaobject
B4X:
...
asJO(tf).RunMethodJO("textProperty",Null).RunMethod("bindBidirectional",Array(asJO(tf).RunMethodJO("getTooltip",Null).RunMethodJO("textProperty",Null)))
...
Sub asJO(o As JavaObject)As JavaObject
Return o
End Sub

Edit: Oops forgot to add - tf is the textfield
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I have found that adding the css in the designer has no effect, and adding it in code using TextField.Style overruns all my previous css styling rendering the view in default css visualy!

 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
even so, why does it overruns the css styling?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I get the same result, but I decided to solve the original question the hard way and created a small sub to trim a passed string to length

B4X:
Private Sub TextToRight (Text As String) As String
    If Text.Length < 40 Then Return Text
    Dim newText As String  = Text.SubString2(Text.Length - 40, Text.Length)
    newText =".." & newText.SubString(newText.IndexOf("\"))
    Return newText
End Sub
.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…