It’s funny that this thread has popped up when it did, as I just last week started working on a module to add “faked” support for native.newTextField() and native.newTextBox() in the Windows simulator. Ed and I have corresponded on this, and it seems like he and I are taking slightly different approaches to the problem, so with his blessing (I didn’t want to steal anybody’s thunder or step on toes), I’m going to make my own solution available here, and on my website later this week, once I have time to compose a blog post around it.
There is a sample project that shows off the various methods and parameters you can apply or adjust to native text inputs attached to this post. You can load that up in the simulator to check it out, or if you want, just copy “windowsText.lua” from that sample project folder and require it into your own project.
The module is only lightly commented, but there is a “how to” section at the top of it. I’ve copied that text at the bottom of this post. The module is set up to overwrite the default native.newTextField() and native.newTextBox() APIs, so you don’t need to change any of your code to use it. If you are running in the Windows simulator, it’ll use the faked APIs - if you are running it on any other platform, it’ll use the native versions. But you can override this behavior by calling windowsText.enable() to force the faked versions on a non-Windows platform, and windowsText.disable() to revert back to the native APIs. The faked text input objects dispatch “userInput” events identical to those put out by their native counterparts, so if you have event listeners for your input fields, they’ll work just fine.
I probably won’t be doing too much support for this module, as it’s not something that would be used in a released app (it’s just a tool to enable text input in the simulator, after all), but if you find any bugs please let me know and I’ll do my best to fix them. In my testing, it works pretty much as advertised, though. Hope some of you find it useful!
-Jason
https://www.youtube.com/watch?v=sPIiMMSb_9E
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* windowsText module for Corona SDK Copyright (c) 2015 Jason Schroeder http://www.jasonschroeder.com http://www.twitter.com/schroederapps \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ABOUT THE MODULE: This module was created to "fake" native text input on the Corona Simulator for Windows, which as of July 2015 does not support the native.newTextBox() and native.newTextField() APIs. You are welcome to modify it as needed, but it is set up to "just work" by requiring it into your Corona project. Once required, the module will check to see if the project is running in the Windows simulator, and if it is, it will overwrite native.newTextBox() and native.newTextField() with these non-native Windows simulator-compatible functions. These modified functions are fully compatible with all syntax and methods of their native counterparts, so you will not need to alter your code at all to support them. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* HOW TO USE THE MODULE: 1.) Place windowsText.lua (this file) in your project's root directory (where your main.lua resides) 2.) Require the module by placing the following code in your main.lua: local windowsText = require("windowsText") 3.) That's it! Calling native.newTextField() or native.newTextBox() will now work in the Windows Simulator just like it does on-device or in OS X. 4.) If you want to use these non-native textFields or textBoxes outside the Windows simulator, you can optionally call windowsText.enable() to overwrite the native functions. You can revert back to the native APIs by calling windowsText.disable() if you wish. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
[sharedmedia=core:attachments:4193]