PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Using standard Apple widgets in Edgelib

martinreddy · 20 Apr 2009, 15:36 UTC
Hey there,

Is it possible to display standard Apple widgets over the top of an Edgelib display on the iPhone? For example, can I add a UITextField over the top of the edge display? All of my attempts to do so have failed so far.

I figured that I should be able to get the key window from the singleton UIApplication, then create a new subview and push it to the front. E.g., in Objective-C:

Code:

CGRect frame = {0, 100, 320, 140};
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UITextField *text = [UITextField alloc] initWithFrame: frame];
[window addSubview: text];
[window bringSubviewToFront: text];


But this does not seem to display anything on the iPhone. Does anyone have any help or suggestions. I'd rather not have to reimplement all of the iPhone's keyboard text entry functionality in Edge.

Cheers,

Martin.
tinybulb.com · 20 Apr 2009, 16:00 UTC
I do not know why keyWindow do not works, but if you will take UIWindow through the GetWindowHandle() from ClassEdge instance everythin will work. I render UITableViews, UIButtons over the EDGE in my game in such way.
martinreddy · 20 Apr 2009, 21:23 UTC
tinybulb.com wrote:I do not know why keyWindow do not works, but if you will take UIWindow through the GetWindowHandle() from ClassEdge instance everythin will work. I render UITableViews, UIButtons over the EDGE in my game in such way.


Thanks for the reply! It looks like GetWindowHandle() returns the same pointer as the UIApplication's keyWindow.

It's good to know that this should be possible, though I still can't get this to work. I have code that works just fine in a vanilla iPhone app, but when I use it in an Edge iPhone app, the UITextField is never visible. I *can* interact with it though - if I click where it should be then the keyboard appears, but I can't see the widget or any of the text that I type. I've tried enabling, unhiding, bringing to the front, etc. with no success.

Any ideas what I'm missing to make the widget visible?

Martin.
tinybulb.com · 21 Apr 2009, 18:50 UTC
I will take a look at this issue later today, maybe will help you wit this. In my own project i used almost all possible UIKit control without any problems. But actually such trick is not recommended by Apple to mix UIKit and OGL ES code:
* Do not place any other Core Animation layers or UIKit views above the CAEAGLLayer object that you’re rendering to.
* Limit interactions between OpenGL ES and UIKit or Core Animation rendering. For example, avoid rendering with OpenGL ES while you render notifications, messages, or any other user interface controls provided by UIKit or Core Animation.
tinybulb.com · 21 Apr 2009, 19:05 UTC
By default UITextField have following settings:
* Black font to render input
* No any border set

As I can suggest you have black background in application, as result do not see reults of your input. To change rendering of app add following line into your code:
Code:
[text setBorderStyle:UITextBorderStyleRoundedRect];


In my application UITextField renders perfectly.
martinreddy · 23 Apr 2009, 15:58 UTC
I think I've found my problem. It seems that Edgelib is calling my OnStylusUp() method in a different (non-main) thread from my OnNextFrame() method.

I believe that if I just make sure that I create the Apple widgets in the main thread then I'll be alright. Just thought I'd mention it in case anyone else runs into similar problems.

Martin.
pocketjoris · 26 Apr 2009, 12:10 UTC
I'd like to do the same thing (use the iphone keyboard for input in my own widgets)

Can anybody point out how to do that? I currently only have cpp files, and I'm quite unfamiliar with obejctive c.

Some sample code that does something like:

mywidget::onFocus() {
showKeyboard();
}

And some code that allows me to trigger keyPress events would be appriciated