5

I'm making a game using libgdx which has a lot of buttons and text fields, I was wondering if there was a Scene2d widget which the user can hover and then a message shows up, something like this.

enter image description here

Kevin Bryan
  • 1,846
  • 2
  • 22
  • 45

1 Answers1

10

These are called Tooltips. There is a built-in one called TextTooltip. If you're using skin, you can create a style like this in Json:

com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
    default: {label: {font: myFont}, background: myBackgroundDrawable, wrapWidth: 400}
}

Tooltips actually are a type of Listener that contain a widget that it temporarily can add to the Stage. You add the tooltip to whatever widget you already have in your layout:

myButton.addListener(new TextTooltip("You can press this", skin));
Tenfour04
  • 83,111
  • 11
  • 94
  • 154
  • thanks for the answer, btw can you look on my other question on stackoverflow, I can't fix the problem and your one of the best when it comes to libgdx, you've been answering my questions for years, thanks http://stackoverflow.com/questions/39774173/libgdx-game-crashes-on-android – Kevin Bryan Nov 08 '16 at 15:16