Hi all (and @void256 in particular ),
Fixed - thanks Madjack
I’m having trouble getting events received using the event bus and was hoping someone could see what I’ve done wrong. I’m dynamically adding panels to the screen using the following code, which works perfectly:
[java]
for (final String button: buttons) {
panel(new PanelBuilder(“NiftyPopupState_”+id+""+button) {{
backgroundImage(“Interface/MenuBackgroundS.png”);
imageMode(“resize:7,1,7,7,7,1,7,1,7,1,7,7”);
paddingLeft(“5px”);
paddingRight(“5px”);
onHoverEffect(new HoverEffectBuilder(“colorBar”) {{
effectParameter(“color”, “#ccc8”);
}});
visibleToMouse();
childLayoutCenter();
text(new TextBuilder() {{
text(button);
font(buttonFont);
color("#fddf");
textVAlignCenter();
textHAlignCenter();
height(LINE_HEIGHT+“px”);
}});
}});
}
[/java]
I’m registered for annotations and I’ve checked this line is called.
[java]
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
nifty.subscribeAnnotations(this);
}
[/java]
But this method never gets called (I’ve breakpointed the first line)
[java]
@NiftyEventSubscriber(pattern="NiftyPopupState*")
public void buttonClicked(String id, NiftyMousePrimaryClickedEvent event) {
[/java]
I know visible to mouse is working as the colourbar works but buttonClicked never gets called (I breakpoint the first line in the method and nothing happens).
Any suggestions?
Thanks,
Z
I think I remember having a similar issue, but that was some time ago.
for my pattern I use:
[java]@NiftyEventSubscriber(pattern=".ListBox");[/java]
If I remember right, the . is important.
Edit:
In your case I guess it would become:
[java]
@NiftyEventSubscriber(pattern="NiftyPopupState_.")
[/java]
1 Like
Ahha! That was almost exactly it. Thanks a lot @madjack!
I changed it to NiftyPopupState_.* and suddenly everything sprung into life. The example in the manual did have im.* but my brain read that in the wildcard/package type sense (i.e. im.[anything] not the regex sense im[anything]).
Ah, doh. I inverted the *. >.<
1 Like