SetSelection for TextFiled?

BlitzPlus Forums/BlitzPlus Programming/SetSelection for TextFiled?

Andres(Posted 2007) [#1]
Is there a way to select a certain characters in a textfield? I'm trying to create a AutoComplete textfield, but i can't find anything about setting selection for a textfield? Or is there's a way to disable multilines in textarea?


UUICEO(Posted 2007) [#2]
I hope you don't mind the messy code.. but this example show's 1 way to do what you are trying to do.. you just need to expand on what I have already done..

Global txtField
Global InfoBox
Global TestWindow
Dim ConfigData$(1)
TestWindow=CreateWindow("TestWindow", (ClientWidth (Desktop ()) / 2) - 200 ,(ClientHeight (Desktop ()) / 2) - 275,200,250,0,5)
	txtField=CreateTextField(1,3,111,20,TestWindow,0)
		SetGadgetLayout txtField,1,1,1,1
	InfoBox=CreateListBox(1,85,180,111,TestWindow)
		SetGadgetLayout InfoBox,1,1,1,1
	AddGadgetItem(InfoBox,"text here")
Repeat
	id=WaitEvent()
	Select id
		Case $401
			DoGadgetAction( EventSource() )
		Case $803
			Exit
	End Select
Forever

Function DoGadgetAction( gadget )
		Idex = CountGadgetItems(InfoBox)
	Select gadget
		Case txtField	;	ConfigData$(1)
			ConfigData$(1) = TextFieldText( txtField )
			If Len(ConfigData$(1)) > 0 Then
				ModifyGadgetItem(InfoBox, Idex - 1, ConfigData$(1))
			Else
				ModifyGadgetItem(InfoBox, Idex - 1, "text here")
			End If
			If Instr(TextFieldText( txtField ), "tes", 1) > 0 Then
				ModifyGadgetItem(InfoBox, Idex - 1, "testing!!")
			End If
	End Select
End Function




Andres(Posted 2007) [#3]
It's not exactly what i need. For example if i have Bill Gates and Bill Bond in my data base and i enter "Bill G" it will automatically add "ates" after it with selection:


Or is there a way to create editable combobox?


UUICEO(Posted 2007) [#4]
you could simply create a list box with the output of the typed in data and when it hits something that's in your database have all that dumped in to the list box to allow the user to either click on the item or let them keep typing, after each new letter typed in the list box would be updated to show the changes in their selection options.


Andres(Posted 2007) [#5]
Yea i could do that, but i would simulate an editable combobox rather than creating another listbox for it. But selecting a certain area of a textfield would require only one function and i need to use that one.