I’d like to make a DropDown widget that uses the data model of Lemur.
I have the Dropdown component (which shows the currently selected item) and the Popup component (which shows all the options to pick). It works by manually passing the String options and the getSelected() return the currently selected option (like on good old awt Choice).
What I’d like to do now is to bind it to an EnumProperty to make it work. In particular, the sample EnumProperty is backed by a DefaultRangedValueModel and I don’t know if it really fits on my component…
Well, I think you can still use that approach if you want. You just need to translate the selection into the enum’s values() index.
int i = (int)model.getValue();
Object o = MyEnum.values()[i])
Presumably your pop-up is a ListBox? You could also tie things together with its selection model.
Since you are already hacking on the code then I guess you can do what you want with enum property, too.
The PropertyPanel is fairly limited in how it resolves things because it was meant to be simple… so stretching it outside of its original intent is going to require a little rewriting as you are discovering. The problem is that jumping off the edge of simplicity instantly gets way more complicated (trust me I know: http://meta-jb.org). It’s hard to be a “little configurable” without jumping in all the way.
…I’ve considered it, though.
That worked for me
Now the TextField. I’d like to add a listener for when the user press Enter (and why not, also copy&paste shortcuts)…
Yeah, you just need to add an action to its action map. If you look in TextEntryComponent you can see examples of how it adds keys to the map. You can do similar things from outside the TextField… for both enter and ctrl-c, etc…