NiftyGui ControlDefinitionBuilder + Right Click?

So, if I understand correctly, if I’m using the ControlDefinitionBuilder to create a new control, I use ControlDefinitionBuilder.interactOnClick() to set the function that will be called when I click on the control being created.

My question is how does one accomplish this for the other buttons (secondary or right button in particular)? I don’t see a “interactOnSecondaryClick()” function, and I tried set(“onSecondaryClick”, “mySecondaryFunction()”) but no dice.

Thanks in advance for your time!

I don’t see a ‘interactOnSecondaryClick’-method either. This is really sad.
Unfortunately one has no chance to implement a own Builder-Class providing this methods because all fields in the ElementBuilder-Class are private.

If you do not need to build your control dynamically you can define your control in a xml-file.
This approach is working although I got an error in the xml-file, but I think this is only a DTD-Problem.

Another approach is the NiftyEventSubscriber.
Just define your method in the corresponding controller and set the id of the interacting element (@NiftyEventSubscriber(id=“myelementid”)) or a pattern defining all matching ids (@NiftyEventSubscriber(pattern=“my.*”) i.e. all ids starting with “my”).

[java]@NiftyEventSubscriber(id=“myelementid”)
public void onClickedSecondaryMouse(String id, NiftyMouseSecondaryClickedEvent event) {
// TODO implementation
}[/java]

1 Like

Yeah, for any more advanced interactions the event subscribers are the way to go.

1 Like

Awesome. Thanks for the help guys!