unintellisense Posted December 7, 2018 Share Posted December 7, 2018 Hello, I am using the GUI InputText, and would like to be able to react to the enter key being pressed. I see there is onBlurObservable, but unless I'm wrong I can't tell from the event whether it lost focus from the enter key or clicking away? The use case I am trying to handle is a chatbox, where the enter key would invoke a function to handle the current contents of the InputText before clearing it. Thanks for reading! Quote Link to comment Share on other sites More sharing options...
Guest Posted December 7, 2018 Share Posted December 7, 2018 Hello! you can probably use scene.onPreKeyboardObservable to register a function when a key will be processed (and use advancedDynamicTexture.focusedControl to check if your inputText is the focused one) unintellisense 1 Quote Link to comment Share on other sites More sharing options...
unintellisense Posted December 7, 2018 Author Share Posted December 7, 2018 Thanks for the response, I see what you mean. I will go ahead and do something like that for now. But, what do you think about a onEnterKeyObservable being added to InputText? I can submit a PR as it seems like it would be a pretty minor change (hardest part is knowing which of the generated files to actually add to my branch for the PR after building, looks like lots of totally unrelated files show diffs)? Quote Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2018 Share Posted December 8, 2018 Your wish is my command:) I added a inputText.onKeyboardEventProcessedObservable Quote Link to comment Share on other sites More sharing options...
unintellisense Posted December 8, 2018 Author Share Posted December 8, 2018 Oh, that works I had just created a more specific onEnterKeyObservable but that works too. Awesome, thanks again! Quote Link to comment Share on other sites More sharing options...
csganja Posted December 8, 2018 Share Posted December 8, 2018 I've done this, but nice addon... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.