how i get a line of text from a textarea in maxgui

BlitzMax Forums/BlitzMax Programming/how i get a line of text from a textarea in maxgui

D4NM4N(Posted 2006) [#1]
Is there a command or way of getting a line of text from a textarea gadget?

something like readline for files would be good


klepto2(Posted 2006) [#2]
The KeyWords are: TextArea_Lines and TextArea_Chars

Small Sample:

' createtextarea.bmx

Strict 

Local window:TGadget
Local textarea:TGadget
Local TextBox:TGadget

window=CreateWindow("My Window",130,20,200,200,,15|WINDOW_ACCEPTFILES)


textarea=CreateTextArea(0,0,ClientWidth(window),ClientHeight(window)/2,window)
SetGadgetLayout textarea,1,1,1,1
SetGadgetText textarea,"a textarea gadget~none line~nandanother"
ActivateGadget textarea

Textbox = CreateTextField(0,ClientHeight(window)/2+10,ClientWidth(window),20,window)


While WaitEvent()
	Print CurrentEvent.ToString()+" "+EventSourceHandle()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_APPTERMINATE
			End
		Case EVENT_GADGETSELECT
			Select EventSource()
				Case textarea
					Local Line:Int = TextAreaCursor(textarea,TEXTAREA_LINES)
					TextBox.SetText(TextAreaText(textArea,line,1,TEXTAREA_LINES).Trim())
			End Select 
	End Select
Wend



TextArea_Lines --> Will always give something back with lines. For example TextAreaCursor(textarea,TEXTAREA_LINES)
will return the current line in which the cursor is. TextAreaCursor(textarea,TEXTAREA_CHARS) will return the correct Cursorposition related to the chars in the text.

So if you use TextAreaText with TEXTAREA_LINES and a length of 1 then the position means the line you want and TextAreaText will return the text of the desired line.


D4NM4N(Posted 2006) [#3]
thanks!


assari(Posted 2006) [#4]
You may also want to check out the TextArea Gadget Tutorial here. See Tutorial 16.