コード例 #1
0
        /**
         * The keyReleased event ensures that the caret-position is updated for both peers, when the
         * user moves the caret with the arrow-keys.
         */
        public void keyReleased(KeyEvent e) {
          int left = e.VK_LEFT;
          int right = e.VK_RIGHT;
          int up = e.VK_UP;
          int down = e.VK_DOWN;
          int home = e.VK_HOME;
          int end = e.VK_END;
          int A = e.VK_A;
          int kc = e.getKeyCode();

          if (kc == left
              || kc == right
              || kc == up
              || kc == down
              || kc == home
              || kc == end
              || (kc == A && e.isControlDown())) {
            if (dec == null) return;
            lc.increment();
            TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp());
            dec.sendObjectToAllPeers(cu);
            er.getEventHistoryLock().lock();
            er.getEventHistory().add(cu);
            er.getEventHistoryLock().unlock();
          }
        }
コード例 #2
0
 public void mouseReleased(MouseEvent e) {
   if (e.getButton() == e.BUTTON1 && connected) {
     if (dec == null) return;
     lc.increment();
     TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp());
     dec.sendObjectToAllPeers(cu);
     er.getEventHistoryLock().lock();
     er.getEventHistory().add(cu);
     er.getEventHistoryLock().unlock();
   }
 }