Hi,
Is it possible to programmatically create a new event that my GUI controls will respond to? I’m trying to catch the “Return” key event in the beginning of my OnGUI function, and in response to this create a “Tab” event so that return behaves like tab. This is what I tried, but it doesn’t work:
if (Event.current.keyCode == KeyCode.Return || Event.current.character == ‘\n’)
{
Event.current.Use();
Event.current = Event.KeyboardEvent(“tab”);
}
Also please let me know if there is another way to make the return key behave as tab.
Thanks,
Oguz
Did you find out how to do this? I can’t seem to figure it out
Input.GetKeyDown(key), where key is some KeyCode enum.
It’s to create a keyboard event not to know when a key is down.
GameObject selected = EventSystem.current.currentSelectedGameObject;
if (selected != null)
{
InputField field = selected.GetComponentInChildren<InputField>();
if (field.isFocused)
{
Event keyEvent = Event.KeyboardEvent(characterToSend);
field.ProcessEvent(keyEvent);
field.ForceLabelUpdate();
}
else
Debug.Log("SendKeyboardEvent: found InputField but it isn't focused. selected gameObject: " + selected.name);
}