Noob question about text input and buttons

Monkey Forums/Monkey Programming/Noob question about text input and buttons

Neil(Posted 2013) [#1]
Hello

I am very new to Monkey and just trying out my fist code (I have a background in VB.NET).

I want to target Android and iOS platforms and I need a single textbox with a submit button. When the textbox is touched I would like a (native) keyboard to appear to allow text to be typed and then the submit button can be touched when finished.

I have searched these forums and looked at various modules but I have to admit I am very confused.

I would really appreciate any pointers to how I can accomplish this.

Later I will also need some sort of drop down menu that will work with Android/iOS.

Many thanks for any help!


ElectricBoogaloo(Posted 2013) [#2]
I should warn you, right off the bat, that Monkey is targeted at Game development, and anything GUI driven is probably better off being done elsewhere.
That's not to say you can't do it, but if you're expecting to "place button, insert text area, accept input" you're going to be going the long way around.

Buttons can either be pre rendered as sprites, or drawn using the Rect, Oval commands.
Once tapped, you should use the EnableKeyboard() command to pop up the keyboard, and then attempt to use the available GetChar commands to read the input, but like I said, this is very much the long way around. It's going to take some work to get it looking like a proper part of the OS, let alone the fact that you won't have any easy way to copy&paste.

Monkey can achieve many things, and I'm sure someone has probably already attempted to create a "real OS GUI" thing, but I imagine anything like that would be target specific, and not so easily multi-target usable.
... But I'm not sure Monkey is the right language to do what you're expecting it to do.

Unless you rethink things in a more game-centric way, you're going to be stumbling over the same issues again and again.


Neil(Posted 2013) [#3]
Thanks ElectricBoogaloo

I suspected as much, and games are what I intend to make. I used to make games many years ago using 6502 machine code on a Commodore 64 and Monkey seemed the ideal language for modern mobile platforms. I just wanted to be able to get keyboard input into a textbox or something for things like player names and hi scores etc. Would be nice if it could be done in an OS type way rather than doing it 'manually'. I will look into your suggestions.


therevills(Posted 2013) [#4]
Have a look at the various GUI modules currently available to Monkey, for example:

* JungleGUI: http://www.monkeycoder.co.nz/Community/posts.php?topic=3253
* MyGUI: http://www.monkeycoder.co.nz/Community/posts.php?topic=5243


Neil(Posted 2013) [#5]
Cheers! Will do ...


Gerry Quinn(Posted 2013) [#6]
The diddy module has a function (look in diddy.externfunctions) that works on Android. However the native code appears to be blank on iOS so I guess for that you need to look elsewhere.

Function ShowAlertDialog:Void(title:String, message:String)
..opens a message box with a virtual keyboard and text input area

Function GetInputString:String()
..gets what the user typed into it


Neil(Posted 2013) [#7]
Thanks for that Gerry. Will look into all the suggestions posted here. Much appreciated.