Пример #1
0
  @Override
  public void onKeyDown(final KyPressedEvent evt) {
    final Accelerator acc = evt.getAccelerator();
    if (acc.getKeyCode() == KeyCode.UNDEFINED) return;

    ModuleInfo moduleInfo = null;

    // look up the module corresponding to this key press
    moduleInfo = moduleService.getModuleForAccelerator(acc);

    // TODO: ask options service whether the default modifier should be forced
    final boolean addModifierAutomatically = true;

    if (moduleInfo == null && addModifierAutomatically) {
      // look up the module corresponding to this key press, plus control
      final KeyCode keyCode = acc.getKeyCode();
      final InputModifiers modifiers = forceDefaultModifier(acc.getModifiers());
      final Accelerator modAcc = new Accelerator(keyCode, modifiers);
      if (!acc.equals(modAcc)) {
        moduleInfo = moduleService.getModuleForAccelerator(modAcc);
      }
    }

    if (moduleInfo == null) return; // no matching module found

    // run via command service, so that preprocessors are run
    moduleService.run(moduleInfo, true, new Object[0]); // FIXME

    // consume event, so that nothing else tries to handle it
    evt.consume();
  }
Пример #2
0
 @EventHandler
 protected void onEvent(final KyPressedEvent event) {
   if (event.isConsumed()) return;
   final Tool aTool = getActiveTool();
   if (eventOk(event, aTool)) aTool.onKeyDown(event);
   for (final Tool tool : getAlwaysActiveTools()) {
     if (event.isConsumed()) break;
     if (eventOk(event, tool)) tool.onKeyDown(event);
   }
 }
Пример #3
0
 @EventHandler
 protected void onEvent(final KyPressedEvent event) {
   if (event.getCode() == KeyCode.ESCAPE) {
     final Display<?> disp = event.getDisplay();
     if (disp != null) {
       if (disp == display) userHasQuit = true;
     } else { // disp == null : event from application bar
       if (imgDispService.getActiveImageDisplay() == display) {
         userHasQuit = true;
       }
     }
   }
 }
Пример #4
0
 @Override
 public void onKeyDown(final KyPressedEvent evt) {
   if (evt.getCode() == CODE[index]) {
     index++;
     if (index > CODE.length - 2) evt.consume();
     if (index == CODE.length) {
       index = 0;
       final ThreadService threadService = getContext().getService(ThreadService.class);
       threadService.run(this);
       final CommandService commandService = getContext().getService(CommandService.class);
       commandService.run(COMMAND);
     }
   } else index = 0;
 }
Пример #5
0
 /** Stops animation if ESC key is pressed. */
 @EventHandler
 protected void onEvent(final KyPressedEvent event) {
   final ImageDisplay imageDisplay = toImageDisplay(event.getDisplay());
   if (imageDisplay == null) return;
   if (event.getCode() == KeyCode.ESCAPE) stop(imageDisplay);
 }