Hi,
I noticed the class TextFieldControl is deprecated, but I just can’t find where to replace it with :s
Somebody who knows?
thx
I don’t know if this talks about it or not:
http://nifty-gui.lessvoid.com/archives/241
Mentions a bunch of similar things, though.
hmm no that ain’t it, I think :s
The changes just happend, like 2 or 3 days ago.
import de.lessvoid.nifty.controls.textfield.TextFieldControl;
username = textUsername.getControl(TextFieldControl.class).getText();
that’s what I’m getting
We updated to the newest version only recently, those functions were considered “deprecated” before but were not really marked with the annotation, thats why you didn’t see it before.
You can still continue using this method, it just might get removed in a future release.
You do
[java]
TextField username = screen.findNiftyControl("controlid", TextField.class);
username.getText();
[/java]
with Nifty 1.3
I’ve added a comment to the @deprecated classes which your IDE should display and point you to the class/interface you should use instead. This should be available in one of the nightly jme3 builds too.
Actually it’s easy: only use classes/interfaces from the “de.lessvoid.nifty.controls” package and not from any of its sub packages anymore. This is done so that we can more freely change the implementation of controls without changing any of the nice new interfaces for the controls.
I don’t know why, but this didn’t work:
TextField user=screen.findControl(“tf_usr_login”,de.lessvoid.nifty.controls.TextField.class);
I got this error:
method findControl in class de.lessvoid.nifty.screen.Screen cannot be applied to given types;
required: java.lang.String,java.lang.Class
found: java.lang.String,java.lang.Class<de.lessvoid.nifty.controls.TextField>
reason: inferred type does not conform to declared bound(s)
inferred: de.lessvoid.nifty.controls.TextField
bound(s): de.lessvoid.nifty.controls.Controller
So, I checked inheritances and stuff and tried this:
TextField user=(TextField)screen.findControl(“tf_usr_login”,de.lessvoid.nifty.controls.AbstractController.class);
And it worked perfectly! so, on a short version:
TextField user=(TextField)screen.findControl(“tf_usr_login”,AbstractController.class);
However (despite I’m happy of being able to solve this), it wasn’t the way @void256 suggested so I guess there’s something wrong anyway (and I updated everything just in case).