Neither of handlers below executed on key pressing:
public class Try_KeyboardInput_01 {
private static final Logger log = LoggerFactory.getLogger(Try_KeyboardInput_01.class);
@SuppressWarnings("serial")
public static void main(String[] args) {
new PFrame() {
@Override
public void initialize() {
PPath circle = PPath.createEllipse(-100, -100, 200, 200);
getCanvas().getLayer().addChild(circle);
circle.addInputEventListener(new PBasicInputEventHandler() {
@Override
public void keyPressed(PInputEvent event) {
log.info("Key pressed on circle");
}
});
getCanvas().getLayer().addInputEventListener(new PBasicInputEventHandler() {
@Override
public void keyPressed(PInputEvent event) {
log.info("Key pressed on layer");
}
});
getCanvas().addInputEventListener(new PBasicInputEventHandler() {
@Override
public void keyPressed(PInputEvent event) {
log.info("Key pressed on canvas");
}
});
}
};
}
}
How to activate the feature?
UPDATE
In some demos I see, that keyboard focus can be turned on from within mouse handler. But this is unacceptable if computer has no mouse, or if keyboard handling should be turned on by default.
How to turn on keyboard handling explicitly?
UPDATE 2
Still didn't understand, if it is possible to set keyboard focus on specific node (without a mouse).