Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

Question: How to capture user text input?

Open evantahler opened this issue 14 years ago • 13 comments

How do you recommend we create a "form" to capture user input (like asking for a user name)? I don't think that your thin document model supports form element, and I can't sort out how to bring up the ios keyboard with the hope of capturing keypress events.

Also, this is an awesome framework.

evantahler avatar Oct 20 '12 18:10 evantahler

Seems like requests like this are tough, because there are so many useful things like this that could go in Ejecta - but I think if anything like this is incorporated it should be as some kind of plugin or add on or something (kind of like Phonegap does) so that the framework stays minimalist and "pure". So, um, can you just add a plugin framework to Ejecta? Thanks ;)

mrspeaker avatar Oct 22 '12 15:10 mrspeaker

Agree. I imagine an interface like ejecta.captureText(successCallback, errorCallback) where successCallback is passed the string input. Any thoughts on the API?

I'll see what I can whip up...

evantahler avatar Oct 23 '12 01:10 evantahler

Popping up a system alert box (i.e. something like this ) wouldn't be too difficult, but it's not pretty and gives you very limited control.

Maybe we should have something like an invisible <input type="text"> that just pops up the keyboard and supports onchange events etc. Drawing the text the user entered would then be the Apps responsibility. Thoughts?

phoboslab avatar Oct 23 '12 13:10 phoboslab

That would work great for my needs!

evantahler avatar Oct 23 '12 14:10 evantahler

What about an UIKit extension? I've started with an implementation of UIScrollView, but definitely starting to see other needs .. UIButton/UILabel/UITextField/etc

khangtoh avatar Oct 24 '12 03:10 khangtoh

I've done the simple thing with the alert box now:

ejecta.getText( 'title', 'subtitle', function(text) {
    console.log(text);
});

If the user taps 'cancel', the 'text' parameter in the callback will be an empty string.

@leftright: you could build these yourself in JavaScript and display with Canvas. Native UI may be nice to have, but I want to keep Ejecta simple and not make it a general purpose UI framework. I guess a plugin system for Ejecta, as @mrspeaker suggested would be a good idea.

phoboslab avatar Oct 28 '12 11:10 phoboslab

Why not change "ejecta.getText" to "prompt"

aki-xavier avatar Nov 01 '12 13:11 aki-xavier

prompt is blocking, while ejecta.getText uses a callback. I'm not really sure how to implement it in a blocking manner; I'd probably have to create the alert box in a separate thread and wait for it. Somehow.

I'll look into it. Having alert() and prompt() instead of custom functions is probably a good idea.

phoboslab avatar Nov 01 '12 15:11 phoboslab

I think these functions should either be blocking or emit custom events to notify the background animation to pause and resume.

aki-xavier avatar Nov 02 '12 08:11 aki-xavier

I might be a bit late to this thread but we implemented Ejecta into PhoneGap about a year ago. https://github.com/Wizcorp/phonegap-plugin-wizViewManager

We also have an Android version but it is not public yet. If there are requests for this we can publish what we have if people are willing to assist on cleaning it up.

aogilvie avatar Apr 26 '13 03:04 aogilvie

Did you implement an Android version of Ejecta?!

weepy avatar Apr 26 '13 10:04 weepy

@weepy For some Ejecta Android fun, check out https://github.com/3dseals/Ejecta-X this is not an official Ejecta port as far as I can tell and its pretty buggy, but might be enough if your requirements are not too high. Ejecta-X is not PhoneGap integrated though.

aogilvie avatar Apr 28 '13 07:04 aogilvie

thanks for the hint. I think I'll be waiting a little while and hope Ejecta-X becomes more stable .... ^_^

weepy avatar Apr 28 '13 09:04 weepy