How do you create a new window on a button click?

I am making a kind of application which requires me to have some sort of a hierarchical menu view, wherein a new page opens after i click a button on the previous page. The button is just a rectangle made using OF itself and no UI interface. What is the best way to go about doing this? I need some help asap.

If you actually want to create a new window you should look into ofxFenster; if you need to simply create new rectangles/images/whatever just create a “page” class with the stuff you need, create a vector of “page” objects and, every time a click is detected in the rectangle area, push_back a new “page” in your vector.

I checked out ofxFenster, it seems that it doesn’t work on the iphone for me. How do I call a new window through open frameworks itself? Or is there a redraw function that I can use??

actually, you don’t need a new window.
all you need is a second draw function or even a section of your draw function that you switch to, when the button is clicked.

i made a multi-page layout for a phone app like that:

void testApp::draw()  
	if(displayIndex == 0) {  
	} else if(displayIndex == 1) {  
	} else if(displayIndex == 2) {  
void testApp::drawPage0()  
	/* do your drawing for page 1 here */  
void testApp::drawPage1()  
	/* do your drawing for page 2 here */  
void testApp::drawPage2()  
	/* do your drawing for page 3 here */  


I have tried what you said above and it doesn’t seem to work. When the function for another drawPage1 is called, the drawing from drawPage0 is still present. I think this is because my ofSetBackgroundAuto is set to false. I can’t set it to true since i need this to be false.

Another option was to make ofSetBackgroundAuto to true everytime it calls the new drawPage function. But this then would remove the drawing from the earlier page and I cant use this since I need the drawing to be retained.

if i understand you correctly, you want a sort of panel overlaid over an existing one. (maybe only partially and even with transparency). in that case you simply add the drawing of that panel at the end of your drawing function and make it conditional. but the old drawing will be affected, once you close that panel, as this might be added to the old drawing. (in that case you would capture the background in a texture for a later restore… )



This is what i really want to do:

Im using UI builder to make menus and on the third or fourth view i need to start my OF window. Then I need another window using OF in another view and switch back and fourth between the two OF views. I don’t wanna keep saving data and using the same page as two views like you mentioned earlier because this seems kinda messy to code. Is there anyway to just begin a new instance of OF in another view??

1 Like

I have been asking the same thing you have since joining this forum!

I was checking this out:

which perhaps get you closer to what you are looking for.

With ofxSceneManger I am still trying to figure out how to create a primary “parent” scene
(which draws 3 separate mousePress areas (defined by ofRectangles).
What I want : Mouse press within the ofRectangle area takes me to a “childe scene” , it times out and goes back to parent scene.

I’ve seen programming layouts like what’s described above more common in javascript , Android, or Java based schemes but I am surprised that I have not found solid examples in
OF yet … :confused: