Skip to content

No way to disable embedded Keyboard-Controls for PopupMenu  #301

Open
@leohilbert

Description

@leohilbert

Hi, first up: thanks for creating this library, it's helping me out a ton! :)
I'm using the PopupMenu in my game and have a few problems with it.
I implemented my own Keyboard-Handling and the Popup-Menu is interfering with it.
The StageListener that get's created during the construction of the object also listens to keyDown-Events and handles UP and DOWN-Presses to skip to the next item.
I would like to disable this functionality, but everything that I would need to overwrite is private:

  • private void createListeners()
  • private InputListener stageListener

I will use reflections for now, but it would be nice to have an option to disable this out of the box.
If you agree I could create a pull-request to simply make the createListeners-Method protected or create a constructor with a boolean "enableKeyboardSupport" in the constructor which is true by default.

Another thing I noticed is that the "void selectNextItem()"-Method of the PopupMenu runs in an infinite-loop, when you have 2 actors added to the popup that are NOT MenuItems.

private void selectNextItem () {
	SnapshotArray<Actor> children = getChildren();
	if (children.size == 0) return;
	int startIndex = activeItem == null ? 0 : children.indexOf(activeItem, true) + 1;
	for (int i = startIndex; ; i++) {
		if (i >= children.size) i = 0;
		Actor actor = children.get(i);
		if (actor instanceof MenuItem && ((MenuItem) actor).isDisabled() == false) {
			setActiveItem((MenuItem) actor, true);
			break;
		}
	}
}

It will search for a MenuItem and never find one, so the Game freezes.

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions