rna access to event.unicode so scripts can get unicode text input.
This commit is contained in:
@@ -471,6 +471,36 @@ static int rna_Event_ascii_length(PointerRNA *ptr)
|
||||
return (event->ascii)? 1 : 0;
|
||||
}
|
||||
|
||||
static void rna_Event_unicode_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
/* utf8 buf isnt \0 terminated */
|
||||
wmEvent *event= (wmEvent*)ptr->data;
|
||||
size_t len= 0;
|
||||
|
||||
if (event->utf8_buf[0]) {
|
||||
BLI_str_utf8_as_unicode_and_size(event->utf8_buf, &len);
|
||||
if (len > 0) {
|
||||
memcpy(value, event->utf8_buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
value[len]= '\0';
|
||||
}
|
||||
|
||||
static int rna_Event_unicode_length(PointerRNA *ptr)
|
||||
{
|
||||
|
||||
wmEvent *event= (wmEvent*)ptr->data;
|
||||
if (event->utf8_buf[0]) {
|
||||
size_t len= 0;
|
||||
BLI_str_utf8_as_unicode_and_size(event->utf8_buf, &len);
|
||||
return (int)len;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
wmWindow *win= (wmWindow*)ptr->data;
|
||||
@@ -1358,6 +1388,11 @@ static void rna_def_event(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
|
||||
|
||||
|
||||
prop= RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_string_funcs(prop, "rna_Event_unicode_get", "rna_Event_unicode_length", NULL);
|
||||
RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
|
||||
|
||||
/* enums */
|
||||
prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "val");
|
||||
|
Reference in New Issue
Block a user