Initial support for text input/edit events

This commit is contained in:
Joshua Granick
2015-05-12 07:11:21 -07:00
parent b1a77a57b1
commit 2d3f51d2a4
19 changed files with 399 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
#include <hx/CFFI.h>
#include <ui/TextEvent.h>
namespace lime {
AutoGCRoot* TextEvent::callback = 0;
AutoGCRoot* TextEvent::eventObject = 0;
static int id_length;
static int id_start;
static int id_text;
static int id_type;
static bool init = false;
TextEvent::TextEvent () {
length = 0;
start = 0;
}
void TextEvent::Dispatch (TextEvent* event) {
if (TextEvent::callback) {
if (!init) {
id_length = val_id ("length");
id_start = val_id ("start");
id_text = val_id ("text");
id_type = val_id ("type");
init = true;
}
value object = (TextEvent::eventObject ? TextEvent::eventObject->get () : alloc_empty_object ());
if (event->type != TEXT_INPUT) {
alloc_field (object, id_length, alloc_int (event->length));
alloc_field (object, id_start, alloc_int (event->start));
}
alloc_field (object, id_text, alloc_string (event->text));
alloc_field (object, id_type, alloc_int (event->type));
val_call0 (TextEvent::callback->get ());
}
}
}