How to create a new window and have the focus back to the main window?

I’m trying to create a new window and get focus back (keyboard events) to the main window.
Right now I can’t do it on macOs, using this code. maybe I’m missing something.

		ofGLFWWindowSettings settings;
		settings.windowMode = OF_WINDOW;
		auto mainWindow = ofGetCurrentWindow();
		settings.shareContextWith = mainWindow;
		for (int a=0; a<10; a++) {
			settings.setSize( 200, 200 );
			int spacing = 25;
			settings.setPosition( { a * spacing + 140, a * spacing + 140 });
			allWindows.emplace_back(ofCreateWindow(settings));
			ofAddListener(allWindows.back()->events().draw, this, &ofApp::drawSecondWindow);
		}
		mainWindow.get()->makeCurrent();

I think you need to use this call:

glfwFocusWindow with the glfw window pointer.
https://www.glfw.org/docs/latest/group__window.html#ga873780357abd3f3a081d71a40aae45a1

makeCurrent is just for OF’s internal window management ( ie: this is the window I want info from when using getWidth / getHeight etc ).

2 Likes