Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by PokerAlicia · Jul 22, 2017 at 12:41 AM · mouseinputfieldwindows store appfocus

UWP, input fields and focus: How can I automatically type in an input field in a UWP app without any use of a mouse?

Hi,

I am creating a mouseless game which involves the player typing into an input field which is automatically put into focus as it appears via these 2 lines:

 EventSystem.current.SetSelectedGameObject(this.gameObject, null);
 GetComponent<InputField>().OnPointerClick(new PointerEventData(EventSystem.current));

I found this to work perfectly in Windows and Mac builds and in the editor, but when I tested UWP, something was not working right. When the input field is created, I couldn't type into the input field like I could in Windows/Mac build despite it being in focus. I know it is in focus because the caret is activated (it wouldn't be if input field is not in focus, I've tested). The interesting thing is if I click with my mouse anywhere on the window of the running app, or if I go to another window (say my web browser) and go back to the app via taskbar, alt+tab or just clicking into it, I am then able to type into the input field (in that instance and every other instance following without clicking anything, as long as I don't close and reload the app).

I have tested both from Visual Studio and via an installed sideload app and both result with this same problem. With the game designed to be played without a mouse, having to click the window to type (even just once) defeats the the whole purpose of what I'm trying to do, so having this seemingly tiny problem be such a major roadblock has been super dismaying. It's also worth noting that the game receives all my other inputs, e.g. navigating with arrows, escape to pause, etc. It is only when it has to do with an input field in a UWP app and only for the first time in a session.

Does anyone have any idea as to what's happening? Any way to fix this or delve deeper into the problem? Does it have anything to do with focus of the UWP app window with the whole having to click the window first? I'm thinking it's plausible, so I've been trying to find a way to force focus on the window without luck; any pointers here? I'm a bit of a greenhorn in programming and making UWP apps, so any help would be great help, thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PokerAlicia · Sep 03, 2017 at 08:10 PM 0
Share

Unfortunately I was not able to find a fix for this, but I applied a hacky workaround that others who encounter this very circumstantial problem might find acceptable.

I ended up starting the game with a screen that prompts the player to click on the screen to start the game. This means the player always has clicked the screen when they try to input an answer and thus will not have issues inputting. I also decided to detail concisely but precisely that this was the only time a mouse was needed (because of the nature of my game).

This is preferable but not ideal. So if anyone has a fix, please do post it here still.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kevin1970 · Oct 21, 2021 at 08:06 PM

You might try checking the "force module active" on the standard input module component of your EventSystem object.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

115 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change caret position inside Input field using mouse position 0 Answers

Prevent InputField from being focused on Start (Text Adventure Game Part 1) 1 Answer

Can't keep the InputField focused 1 Answer

Hide the curser the moment i press play not having to press the play window 0 Answers

Event on mouse up 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges