What you need to use is the .NET “System.Windows.Controls.TextBox” class, which supports single line and multiline text.
http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox(v=vs.110).aspx
The tricky part is positioning it on the screen. If you want to position the text box relative to Corona’s content coordinates, that’s much more difficult. Instead, I recommend that you do something simpler and create your own “User Control” that you can display as a popup window in the middle of the screen containing all of the native text fields, labels, and buttons you need.
Here’s a quick step-by-step procedure on how you can do this:
-
Go to the “Solution Explorer” panel in Visual Studio.
-
Right click on the project node in the tree. It’s the child node under the root “Solution” node.
-
Click on “Add\Item” in the popup menu.
-
Select “Windows Phone User Control” in the list and give the control a name like “MyPopup.xaml”. (You can give it a better name later.)
-
Visual Studio’s UI designer will now show you a blank user control that you can design.
-
In Visual Studio’s “Toolbox” panel, you can drag-and-drop control such as TextBoxes and Buttons to your user control. Go ahead and do so (for testing purposes) and then click save.
-
Open your “MainPage.xaml.cs” file in Visual Studio.
-
Add the following code to the bottom of the MainPage() constructor to display your user control on startup.
var myPopup = new MyPopup(); myPopup.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; myPopup.VerticalAlignment = System.Windows.VerticalAlignment.Center; fCoronaPanel.Children.Add(myPopup);
That’s it! You’ve now create a user control that can be used to display a native popup onscreen. The next trick is to use Corona’s native-to-lua bridge so that your Lua script can display the popup instead of doing so in your MainPage constructor (which was just for testing purposes). The cool thing about this approach is that you can use Visual Studio’s nice UI designer to layout the popup exactly the way you want it… and your user control is its own C# class and can control the text input and button input itself. You’ll probably want to play with Microsoft’s layout panels too so that it’ll be sized nicely on different resolution displays, such as via a “StackPanel” class.
In any case, I hope this will be a good start for you. The steps may look long up above, but I’m just being detailed. This is actually a very simple way to create your own native input popups.