This example is a libGDX demo that shows the Focusable Stage in action
-
Copy the
FocusableStagefile into your project and import it -
Replace
StagewithFocusableStage:Stage stage = new Stage(viewport);-->FocusableStage stage = new FocusableStage(viewport); -
Add all
Actors that you wish to have focus capabilities, similar to how you would addActors 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
setFocusedActorto focus a particularActor:stage.setFocusedActor(textbutton3);
TABfor focusing the next ActorSHIFT+TABfor focusing the previous ActorLEFTfor focusing the previous ActorRIGHTfor focusing the next ActorUPfor focusing the above ActorDOWNfor focusing the below ActorEnterorSpacefor 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
