Nifty EventBus retrieve Keyboard Events. HOW?

Probably a stupid simple question but I’ve searched for hours and I can’t find anything.

I have an Element(Panel). It is Focused and accepting Keyboard inputs. I’m typing a Key from my Keyboard.
I want something to happen and I want to do it using the EventBus(using @NiftyEventSubscriber).
HOW?

In the xml -> …<Panel id=“someID” … > … </Panel> …

In the code -> nifty.subscribeAnnotations(someObject);

In someObject’s Class -> @NiftyEventSubscriber(id = “someID”)
public void? onKeyTyped(String?? id, NiftyInputEvent?? e) { stuff happens }

What is that method supposed to look like? Is it void? Does it have any other parameters?
Does it actually exist?
I cannot find any example of this.

All the other events I’ve tried work just fine.
If I use a Controller the event works just fine.
But I do NOT want to use a Controller.
And I do NOT want to use a Control. It has to be a simple Element.
And this Has to happen when I press a Key and in no other way.

Thank you.

Quoting the manual:

This is probably the simplest way to register for events with Nifty. It uses the @NiftyEventSubscriber annotation with the id of the element we‘d like to receive events for. The annotation will work with single methods. The annotated method is required to have exactly two parameters: - The first parameter must be a String and will contain the elementId that has published the event. - The second parameter will be an instance of a class that implements the NiftyEvent interface.

So basically yuo are in the right direction and a valid method should be something like this :
[java]
@NiftyEventSubscriber(id = “someID”)
public void onKeyTyped(String id, NiftyInputEvent e) { stuff happens }
[/java]

Remember that the element should have the focusable attribute set to true .

Yes. It should work. But it doesn’t :stuck_out_tongue:
That’s the 1st thing I tried.
I also tried with boolean method instead of void like in Controllers.
I also tried with all sorts of Events, including other KeyEvents other than Nifty’s.
I tried adding/removing different attributes from the tag. Using my own KeyMappings.

The only thing remaining that I can think of is that I’m not using the right method.
But I cannot find any example/signature/code/anything describing it.

When an element is enabled to retrieve keyboard events the converted NiftyInputEvent itself is published using the id of the element.

That is only thing the manual says about this. 1 sentence. Does this Actually exist ? :-?
Again ALL of the Mouse/Control events are working. And using controllers to handle Key strokes also works.

Ty for the reply tho.

Digging in to nifty code seems that without a controller the element won’t send any NiftyInputEvent … Anyway adding a controller I can’t make this works … You should report this issue on github issue tracker maybe some other can help! :slight_smile:

p.s. Also mention that you are using 1.3.3 vesion :slight_smile: