-2

I have not found a similar question anywhere, so I decided to post. The problem is that texttooltip is not showing on element on android, though works perfectly on desktop launch. I added some sysouts and app seems to detect enter and exit events correctly(desktop shows same console output), but for some reason tt still wont popup. The objective is so when user holds the element(touchable), app shows a texttooltip. What may be the problem?

Edit: I have tried extending TextTooltip, overriding enter() and exit() methods and only adding sysout to them. Holding finger on button with my TextTooltip triggers enter() once and releasing a finger triggers exit() once. Like hovering a mouse on desktop, same output. Only difference is actual tooltip not showing up.

redy5
  • 11
  • 1
  • Can you share what you have tried? – tomerpacific Nov 12 '19 at 11:49
  • Tried adding text tooltips to all kind of elements: touchable tables, buttons, windows, labels. Tried tweaking TooltipManager settings, didnt help. Tested it all on desktop and it worked as intended. I also never encountered any issues with scene2d on android so far. – redy5 Nov 12 '19 at 11:57
  • 2
    Welcome to SO. Please show us ur code. Have a look at [how to ask a question](https://stackoverflow.com/help/how-to-ask) and provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) so others can actually help you. – Erbsenkoenig Nov 12 '19 at 12:15
  • Which gdx version are you using? There were bugs with ToolTips on Android in the past. – MrStahlfelge Nov 13 '19 at 08:47
  • I have built a project with gradle this month, so Im pretty sure the version is up to date. Those bugs were fixed few years ago so thats definetely not the case. – redy5 Nov 13 '19 at 17:04

1 Answers1

1

Okay I fixed this. Maybe it helps anyone with similar os same issue.

public class HoldTooltip extends ActorGestureListener {

Label tooltip_text;
Table tooltip_actor;

public HoldTooltip(String tooltip_text) {
    this.tooltip_text = new Label(tooltip_text, skin);

    tooltip_actor = new Table();
    tooltip_actor.add(this.tooltip_text);
    tooltip_actor.setSize(this.tooltip_text.getPrefWidth(), this.tooltip_text.getPrefHeight());

    getGestureDetector().setLongPressSeconds(0.5f);
}

@Override
public boolean longPress(Actor actor, float x, float y) {
    tooltip_actor.setPosition(x+50, y+50);
    actor.getStage().addActor(tooltip_actor);
    return super.longPress(actor, x, y);
}

@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
    tooltip_actor.remove();
    super.touchUp(event, x, y, pointer, button);
}

Basically I just redone the stock TextTooltip, the difference being this one actually works as intended. If you want cool animations just add a sequence when adding or removing tooltip_actor to stage.