[Nifty1.3] Looking for custom control inside an Element (Solved)

Hello,



I have developped some custom controls for my project.

Some of them are using other controls developped by my self.

Example :

[java]

@Override

public void bind(

final Nifty niftyParam,

final Screen screenParam,

final Element elementParam,

final Properties propertiesParam,

final Attributes controlDefinitionAttributes)

{

mainElem = elementParam;

mainElem.setFocusable( false );

skillIcon = mainElem.findControl( “skillButton”, ActionButtonControl.class );



xpBar = mainElem.findControl( “xpBar”, FillingTubeControl.class );

hitBar = mainElem.findControl( “hitBar”, FillingTubeControl.class );

[…]

}

[/java]

The error says :

The method findControl(String, Class) is undefined for the type Element



It seems the class de.lessvoid.nifty.elements.Element contains a method findNiftyControl(…) but have lost the previous method findControl(…)



Does it means that I have to convert all my custom control that are used inside others to Nifty Controls ?



If that’s the case, can you briefly ( or give me a link ) on how to convert classic controls to nifty controls.



For what I’ve seen in http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Nifty_Standard_Controls_(Nifty_1.3)

I must implement the interface NiftyControl on my controls.

But I doubt It will be enough :slight_smile:

I’m sorry, that method has been temporarily removed because sometimes I’m a little bit retarded :slight_smile:



You don’t need to convert your own controls to NiftyControls at all! I’ll bring that method back with on of the next commits to Nifty :slight_smile:



In the meantime you can use element.findElementByName(String id) to find your control by the controlId (the first parameter of the old method) and then call getControl(Class requestedControlClass) to get the actual control. The old findControl() method actually did the same internally too :slight_smile:



My apologies!

Thanks for the tips !

I will try to use that to see if the rest compile :slight_smile: