[Libgdx] setting the stage Ydown

I have been working with scene2d.ui stage

this is the stage initialization


OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(true);
				
ScreenViewport SV = new ScreenViewport(cam);
			
stage = new Stage(SV);

the reason I have cam.setToOrtho(true);
is because I want the 0,0 to be up in the top left

the text input works if it is given focus at first
but I can not click on it to give it focus

hey

so the class youve got that in extends stage ?
or do you create a stage in your class ?
cause youve got to consider, a stage got its own camera and spritebatch.
you can get them with :

this.getCamera().do_fance_stuff_here();
this.getSpriteBatch()do_fance_stuff_here()

I am just using the default Stage using the screenViewport and pass a new orthographic camera with ydown set. the problem I am having is it seems like the bounding box for the buttons and text fields are not matching up.

I suppose that the Stage should also know you are rendering things upside down? If you flip the rendering but not the input coordinates then clicks are registered upside down. You should tell the Stage that you are using Y-down coordinates.

Here’s an example that does what you want (I think):
http://libgdx.googlecode.com/svn/trunk/tests/gdx-tests/src/com/badlogic/gdx/tests/YDownTest.java

ah yes I have come across this so many times it is becoming annoying, in the current version of Libgdx the Stage class has changed since this.

in the old one what you would do would be

Stage stage = new Stage(Width,Height,true);

where Width and Height would be your screen size

but now stage only takes as a parameter the class Viewport

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/viewport/Viewport.html

and neither it nor its children classes take the same parameters as the old stage