Also tried by replacing Button with AButton on different places, didn’t help.
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.simsilica.lemur.ActionButton[text=Campaign mode, color=Color[1.0, 0.5, 1.0, 1.0], elementId=ElementId[small.button]]' with class 'com.simsilica.lemur.ActionButton' to class 'com.pesegato.p8s.sdk.amethyst.AButton'
or
MissingMethodException: No signature of method: com.simsilica.lemur.ActionButton.callBack() is applicable for argument types: () values: [] Possible solutions: click(), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)
Yes, because you must be attaching it to all kinds of buttons that aren’t just AButton.
Groovy is basically Java here… there’s no magic. If you get an error about something you’d get in Java then it’s a Java error. Here your attaching a thing that’s trying to cast its source to AButton to things that are not AButton.
So do an instanceof check if you want to operate that way.
And then you never need the case either way. If the code is valid in the first place, you NEVER HAVE TO CAST in groovy. Dynamic dispatch.
Note: in Lemur master I’ve added ButtonAction.Enabled/Disabled:
…and the appropriate code to call those when enabling/disabling a button. (I’ve also added runEffect calls for the new EFFECT_ENABLE/EFFECT_DISABLE, for what it’s worth.)
These will be in the next release… or if you build Lemur from source you can have them already.