TextInput: fix for crash when setting focus (closes #371)