Пример #1
0
    public void keyPressed(KeyEvent e) {
      int keyCode = e.getKeyCode();

      System.out.println(keyCode + ", " + e.getKeyChar()); // testing

      // When shift is held, the user has entered editing mode
      if (e.isShiftDown()) {
        editingMode = true;
      } else {
        editingMode = false;
      }

      if (keyCode == KeyEvent.VK_SPACE)
        // Stop all stoppable sounds
        soundManager.stopSounds();
      else {
        SoundInfo sound = soundManager.getSound(keyCode);
        if (sound != null) {
          // Play, stop, or edit the sound
          dialogManager.handleSoundEvent(sound);
        } else if (getEditingMode()
            && keyCode != KeyEvent.VK_SHIFT
            && keyCode != KeyEvent.VK_CAPS_LOCK) {
          // Create a new sound
          dialogManager.displayNewSoundDialog();
        }
      }
    }
Пример #2
0
 // Exit editing mode when shift is released
 public void keyReleased(KeyEvent e) {
   if (!e.isShiftDown()) {
     editingMode = false;
   }
 }