Log in or register to post comments

Adding popup to EAGLView

July 26, 2012 - 6:36am #1
Hello, I'm trying to modify VirtualButtons sample to show a popup whenever a button is pressed. I added a UILabel to EAGLView.h. In initWithFrame I setup the label and added it: [self addSubview:popupLabel];

At this point it shows up as expected. But now I'm trying to change the text dynamically and it's not working somehow. What I would like is to change the text depending on which button is pressed. I thought I would just have to change the label text in if (button->isPressed()) but somehow this doesn't work.
 
If I put 'popupLabel.text = @"text" in postInitQCAR, the label changes but when I place the text in renderFrameQCAR it doesn't work.
If I change the label both in postInitQCAR and renderFrameQCAR, it works if I put the code before [self setFramebuffer];

For example:
 
popupLabel.text = @"render 2";
[self setFrameBuffer];
popupLabel.text = @"render 3";
 
The text shows up as 'render 2' instead of 'render 3'.
 
Can someone help me? 
 
native SDK: vuforia-sdk-1-5-8

MacOS version number: 10.6.8

Xcode version number: 4.2

iPhone 4 GSM

iOS version: 5.1.1



Adding popup to EAGLView

July 27, 2012 - 7:49am #6

Excellent news :)

Adding popup to EAGLView

July 27, 2012 - 7:05am #5

That did it! Thank you! It's working now.

Adding popup to EAGLView

July 27, 2012 - 6:45am #4

"I placed the changing text code inside renderFrameQCAR "

Put this inside another function called say showMessage , but then call that function from within renderFrameQCAR

[self performSelectorOnMainThread:@selector(showMessage:) withObject:message waitUntilDone:NO];

where message is the text you want to set it to.

Does this make sense - need to try it and see if it works...

 

N

 

 

Adding popup to EAGLView

July 27, 2012 - 6:29am #3

Hi NalinS, thanks for replying.

I couldn't find in existing samples, UI interacting with virtual button press event (which seems not an event really, just something that's getting checked all the time while tracking).

I placed the changing text code inside renderFrameQCAR because that's where the virtual button press event is happening. If I moved the function to the main thread how would I get this event?

 

Adding popup to EAGLView

July 27, 2012 - 4:46am #2

Hi cekk,

This might be because renderFrameQCAR is executed via a background thread.

So one thing you could try is to execute the function to change the text on the main thread e.g.

- (void) displayMessage:(NSString*) message

{

    [self performSelectorOnMainThread:@selector(showMessage:) withObject:message waitUntilDone:NO];

}

 

...where showMessage() is the method you have created to set the UI label as you need.

 

The other option is to see how the existing samples handle UI, as they use use an overlay controller to handle GUI.

 

HTH

 

N

Log in or register to post comments