pulsaciones de teclas mango utilizando SWT
-
28-09-2019 - |
Pregunta
Estoy quiero hacer someStuff () cuando CTRL-C presionado. Yo había escrito algo de código, pero "no es suficiente". ¿Qué puedo hacer con ella?)
//org.eclipse.draw2d.Shape getShape(){....}
getShape().addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent ke) {
}
@Override
public void keyReleased(KeyEvent ke) {
/*if CTRL-C pressed*/
if((ke.getState() & KeyEvent.CONTROL) != 0 && 'c' == ('a' + ke.character - 1)){
someStuff();
}
}
});
Gracias.
Solución
Prueba esto:
getShape().addListener(SWT.KeyUp, new Listener() {
public void handleEvent(Event event) {
if (event.stateMask == SWT.CTRL && event.keyCode == 'c') {
someStuff();
}
}});
Otros consejos
Trate de usar la siguiente condición para comprobar CTRL-C:
public void keyReleased(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.VK_C && event.getModifiers() == InputEvent.CTRL_MASK)
someStuff();
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow