[clutter-text] Don't allow control characters to be inserted

If an unbound control key is pressed (such as Ctrl+R) it would insert
a rectangle into the text.

Also zero is considered a valid unicode character by
g_unichar_validate so pressing a key such as shift would cause the
current selection to be deleted. The character isn't actually inserted
because insert_unichar disallows zeroes.
This commit is contained in:
Neil Roberts 2009-01-13 17:52:38 +00:00
parent de114dead7
commit e93c266647

View File

@ -1017,7 +1017,9 @@ clutter_text_key_press (ClutterActor *actor,
if (key_unichar == '\r')
key_unichar = '\n';
if (g_unichar_validate (key_unichar))
if (key_unichar == '\n' ||
(g_unichar_validate (key_unichar) &&
!g_unichar_iscntrl (key_unichar)))
{
/* truncate the eventual selection so that the
* Unicode character can replace it