TextBox Cursor

RandomCoder

Well-Known Member
Licensed User
Longtime User
I'm in need of some :sign0085:

My editable table program (http://www.b4x.com/forum/showthread.php?t=487) could be made better if the data in the TextBox was highlighted ready to be overwritten with new data.

This seems to have got the better of me even though I'm certain it must be possible.
So far I've tried turning the Focus onto the TextBox but this didn't work, I then tried selecting whatever data was in the TextBox but still no joy.
What else is there to do :confused:

Anyway, here's what I've already tried....
B4X:
   TextBox1.Focus=True
   TextBox1.SelectionStart=0
   TextBox1.SelectionLength= StrLength(TextBox1.Text)

Any takers on what I'm doing wrong?

Thanks,
RandomCoder
 

Cableguy

Expert
Licensed User
Longtime User
Well randomcoder,

For starters, the focus method does NOT require to be True or False.
The correct syntax is textbox1.focus.

With that corrected it works fine, the text in textbox1 gets highlighted...Both on desktop(no code needed) ond ppc(with the code).
 

specci48

Well-Known Member
Licensed User
Longtime User
Hi RandomCoder,

I took my posted EditableTablev1.1 and changed the Sub Timer_Tick into
B4X:
Sub Timer1_Tick
    Timer1.Enabled = false
    TextBox1.SelectionLength = StrLength(TextBox1.Text)
    TextBox1.Focus
End Sub

I don't know why this must be done out of the SelectionChanged sub. :(

specci48
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
CableGuy,

I feel that you are my friend and we joined roughly the same time but just so that you know, I did try TextBox1.Focus but that didn't work and so I used the full syntax just to try and dot all the i's and cross all the t's as it were.
You obviously didn't try it in my EditableTable App as it definitely does not work :(

Specci48,

Thank you, you've come to my rescue :sign0060:
The SelectionChanged Sub must have been keeping hold of the Focus.
The only problem now is that I suspect that I won't be able to use the arrow keys on the SIP to navigate around the table since the Focus is no longer on the Selected Cell.
I'll have to try this on the device to confirm this but at the moment am just putting my kids to bed.

Thanks,
RandomCoder
 

Cableguy

Expert
Licensed User
Longtime User
You are rigth ...and wrong...

I didn't try it in you editable table, I tryed it in a blankform with only a texbox in it, and it works...
In you first post you didnt specified that this was to be in the selection change event....

I never doubt of you skills as myself make a few dumb mistakes once in a while....

Never the less, Im glad your prob is solved....
 
Top