Textfield.SetFocus & Cursors

Hi all,

I am having some trouble with a textfield. I want any key input on a window to be directed to the textfield.

I put this in the Window.Keydown event:

if AscB(key)>31 and ascb(key)<127 then
searchField.Text=key
searchField.SelStart=1
searchField.SetFocus
searchField.TabIndex=0
end if
return false

Should this not set the textfield’s text to the key pressed by the user and also put the cursor at the end?
However all it does is continually overwrite the searchField with 1 character. The searchfield.SetFocus does not place the cursor into the searchfield; the Window retains the focus somehow in that the Window.Keydown event keeps getting called no matter how many times the searchfield.Setfocus is called.

Use searchfield.appendtext rather than .text and lose the selstart. You don’t want the cursor at the beginning. Do not know about the setfocus without some experimenting. Maybe try self.clearfocus before setfocus. Then you will need vide in the searchfield.keydown to catch subsequent entry.

calling ClearFocus before searchField.SetFocus fixes the issue and places the actual blinking cursor into the textField.

How bizarre. I think this has been introduced rather recently as just a normal SetFocus used to put the cursor into the textField.