For my current project, I’ve finally started to learn Lemur.
I have an appstate that handles a set of related input functions, specifically the hotkeys I use for debugging. I’ve grouped the functions together using a Lemur input group. In the appstate’s onEnable()
and onDisable()
methods, I can conveniently (de)activate all functions in the group using InputMapper.activateGroup()
and InputMapper.deactivateGroup()
.
In my initialize()
method I want to map all functions in the group. I wound up doing:
Set<FunctionId> functions = inputMapper.getFunctionIds();
for (FunctionId function : functions) {
String group = function.getGroup();
switch (group) {
case G_DUMP:
inputMapper.addStateListener(this, function);
}
}
In my cleanup()
method I want to unmap all the functions and remove them from the state listener. I wound up doing:
InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper();
Set<FunctionId> functions = inputMapper.getFunctionIds();
for (FunctionId function : functions) {
String group = function.getGroup();
switch (group) {
case G_DUMP:
Set<InputMapper.Mapping> mappings
= inputMapper.getMappings(function);
for (InputMapper.Mapping mapping : mappings) {
inputMapper.removeMapping(mapping);
}
inputMapper.removeStateListener(this, function);
}
}
Seems to me there ought to be simpler ways to accomplish these basic tasks. Is there? And if so, what would it be? Or am I misusing function groups somehow?