File tree Expand file tree Collapse file tree 1 file changed +23
-17
lines changed Expand file tree Collapse file tree 1 file changed +23
-17
lines changed Original file line number Diff line number Diff line change 66
77namespace UXF
88{
9- /// <summary>
10- /// A script that can be added to an object with an input field, when enter is pressed while editing the input field a UnityEvent will be invoked
11- /// </summary>
12- public class InputFieldKeyboardReturnEvent : MonoBehaviour
13- {
14- private InputField inputField ;
9+ /// <summary>
10+ /// A script that can be added to an object with an input field, when enter is pressed while editing the input field a UnityEvent will be invoked
11+ /// </summary>
12+ public class InputFieldKeyboardReturnEvent : MonoBehaviour
13+ {
14+ private InputField inputField ;
1515
16- public UnityEvent onReturn ;
16+ public UnityEvent onReturn ;
1717
18- void Start ( )
19- {
20- inputField = GetComponent < InputField > ( ) ;
21- }
18+ void Start ( )
19+ {
20+ inputField = GetComponent < InputField > ( ) ;
21+ }
2222
23- void OnGUI ( )
24- {
25- if ( inputField . isFocused && ! string . IsNullOrEmpty ( inputField . text ) && Input . GetKeyDown ( KeyCode . Return ) )
26- onReturn . Invoke ( ) ;
27- }
28- }
23+ void OnGUI ( )
24+ {
25+ if ( inputField . isFocused &&
26+ ! string . IsNullOrEmpty ( inputField . text ) &&
27+ ( Input . GetKeyDown ( KeyCode . Return ) || Input . GetKeyDown ( KeyCode . KeypadEnter ) ) )
28+ {
29+ onReturn . Invoke ( ) ;
30+ inputField . Select ( ) ;
31+ inputField . ActivateInputField ( ) ;
32+ }
33+ }
34+ }
2935}
You can’t perform that action at this time.
0 commit comments