This example is a libGDX demo that shows the Focusable Stage in action
-
Copy the
FocusableStage
file into your project and import it -
Replace
Stage
withFocusableStage
:Stage stage = new Stage(viewport);
-->FocusableStage stage = new FocusableStage(viewport);
-
Add all
Actor
s that you wish to have focus capabilities, similar to how you would addActor
s into aTable
:stage.addFocusableActor(new TextButton("button 1", skin), 3); // 3 signifies the colspan of the Actor; default is 1 if you omit it stage.addFocusableActor(new TextButton("button 2", skin)); // Uses 1 colspan because the second argument was omitted stage.row(); // Used to signify the end of a row just like `Table`s
-
Optionally, use
setFocusedActor
to focus a particularActor
:stage.setFocusedActor(textbutton3);
TAB
for focusing the next ActorSHIFT
+TAB
for focusing the previous ActorLEFT
for focusing the previous ActorRIGHT
for focusing the next ActorUP
for focusing the above ActorDOWN
for focusing the below ActorEnter
orSpace
for pressing the currently focused Actor
provided the currently focused actor is not busy
This example uses the neon-ui skin made by Raymond "Raeleus" Buckley using Skin Composer which is licenced under CC BY 4.0