getting the string of line from ifsogui textbox...

BlitzMax Forums/BlitzMax Beginners Area/getting the string of line from ifsogui textbox...

Takis76(Posted 2015) [#1]
Hello,

I am working in my game and I am creating the console.
The place you can execute commands like cheats and other development things.
I use the ifsogui and I have created one multiple line text box.

I would like to try to grab the text of one line of the text box and the
see if the text contains any command.

For example if I type "cls" or "clear" to clear the whole textbox. Or create some cheats. :D


The creation code:

global The_console:ifsoGUI_MLTextBox
The_console = ifsoGUI_MLTextBox.Create(0, 0, 640, 100, "Game console")
The_console.SetGadgetAlpha(console_alpha)
The_console.SetShowFocus(False)
The_console.SetVScrollbar(False)
The_console.SetHScrollbar(False)
The_console.SetTextColor(0, 255, 0)
The_console.Visible = True
	
GUI.AddGadget(The_console)


I tried some tricks to capture the text like this:

	Local c_text:String
	Local c_char_pos:Byte
	
		For c_char_pos = 0 To Len(The_console.GetValue())
			c_text = "" + Left(The_console.GetValue(), c_char_pos)
		Next
		
		
	DrawText(c_text, 500, 140)


The code above captures the text in some string variable but it captures whole line. Is similar to The_console.GetValue()
I would like when I am pressing enter to capture only the last line in the multiple line textbox.
Or how is it possible to read the last line of the textbox when I am pressing enter or read the current line of the cursor only and when I am pressing enter to return this text to string variable.

:) Thank you


grable(Posted 2015) [#2]
It would probably be easier to have 2 controls, one for input and one for display.
And after browsing through the code i see it has a Filter function which you can use to trap the return key and then do your checking.

Anyway, to get the last line do:
The_console.Lines[The_console.Lines.Length-1]



Takis76(Posted 2015) [#3]
Your code capture the last line I want.
How do I use the filter command?

The_console.Filter(KEY_ENTER, ifsogui_base)

It asks the ifsogui_base argument which I don't know what to put.

:)


grable(Posted 2015) [#4]
Its a function pointer, and it is called when the control detects input.
The second argument is there for you to detect which control calls it, if several controls share the function.
There is a method to set it, SetFilter i believe.

You really should read the source, at the very least check what fields and methods the types have.
Then you would know how to use ifsogui better ;)

EDIT: For completeness, the filter function would look something like this..
FilterEnter:Int( key:Int, gadget:ifsoGUI_Base)
  If key = KEY_ENTER Then
    Local this:ifsoGUI_MLTextBox = ifsoGUI_MLTextBox(gadget)
    Local line:String = this.Lines[this.Lines.Length-1]
    Print "last line: " + line
  EndIf
  Return True
EndFunction



Takis76(Posted 2015) [#5]
Yes there is a problem , there is no manual.
When I was purchased ifsogui I downloaded only 2 examples and was 5 as I remember. And there is no manual at all.

I continuously I don't understand this ifsoGUI_Base which asks.
In generic I don't understand much about object oriented programming with blitzmax.
So I created the trick little elsewhere.
I created one simple textbox and one listbox.
And when I type something I get the text from the simple textbox and I add it to listbox and the effect is similar.

Thank you again.