Sign in to follow this  
Infinite_Daremo

Bringing up the iPhone keyboard Simulator in an OpenGL app?

Recommended Posts

Is this possible? It seems most of the functionality is embedded into the UITextField or UIResponder, but i can't find anything to bring up the keyboard without this, i tried a small hack like this: UIResponder *resp = [[UIResponder alloc] init]; [resp becomeFirstResponder]; But nothing appeared. It may work but i dont know if the OpenGL rendering is being done over the top of it everytime. This isn't a huge deal, i can design my own UI input but why re-write the wheel. Thanks for any info.

Share this post


Link to post
Share on other sites
You might be able to render the UIKit views (and thus controls) into a texture, and then composite into your scene, much as you can with Cocoa. Event handling, unfortunately, is still up to you.

In Cocoa you can set the level of the OpenGL view to be lower than that of the controls, but I have a feeling that the iPhone is limited to fullscreen OpenGL contexts, to save precious resources.

Share this post


Link to post
Share on other sites
Some people on other boards suggest creating an invisible textfield (1x1) and using that to popup the keyboard. I strongly suggest using the built in apple keyboard as it handles all localization issues as well as being maintained by apple. I believe u can draw widgets over the opengl surfaces, as I've seen games do this.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Please just use the UITextField and the system keyboard. I would even advise against the 1x1 TextField approach, since the keyboard UI visually interacts with the text field to provide autocorrection.

I would just place the UITextView on top of your GL view when input is needed, and remove it otherwise.

Share this post


Link to post
Share on other sites
Quote:
Original post by frogblast
I would just place the UITextView on top of your GL view when input is needed, and remove it otherwise.
Yeah, I tried this today and was very surprised it worked - pretty sure it didn't under the original iPhone OS.

Share this post


Link to post
Share on other sites
Does any one know of a tutorial on how to manually create a UITextView or UITextField, I don't know coco touch and I don't want to learn it just for this thing. Every thing I need is those few lines for setting up the thing, every thing else is cover in this tutorial: http://developer.apple.com/iphone/library/samplecode/HelloWorld_iPhone/index.html


Thanks!



EDIT: found it
UITextField *username =[[UITextField alloc] initWithFrame:CGRectMake(24.5, 65, 270, 30)];
username.delegate=self;
username.textAlignment=UITextAlignmentCenter;
username.borderstyle=UITextBorderstyleRoundedRect;
username.placeholder=@"Username\n";
username.autocorrectionType=UITextAutocorrectionTypeNo;
username.autocapitalizationType=UITextAutocapitalizationTypeNone;
[self.view addSubview:username];


[Edited by - oioioi on June 20, 2009 5:13:09 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by oioioi
Does any one know of a tutorial on how to manually create a UITextView or UITextField...
Generally, I would recommend designing each of your UI screens as views in Interface Builder. Then you can swap in views as needed, over the top of your OpenGL view.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this