Пример #1
0
 /** Sets or clears the caret in the "Example" widget. */
 void setCaret() {
   Caret oldCaret = canvas.getCaret();
   if (caretButton.getSelection()) {
     Caret newCaret = new Caret(canvas, SWT.NONE);
     Font font = canvas.getFont();
     newCaret.setFont(font);
     GC gc = new GC(canvas);
     gc.setFont(font);
     newCaret.setBounds(1, 1, 1, gc.getFontMetrics().getHeight());
     gc.dispose();
     canvas.setCaret(newCaret);
     canvas.setFocus();
   } else {
     canvas.setCaret(null);
   }
   if (oldCaret != null) oldCaret.dispose();
 }
Пример #2
0
 void createWidget() {
   createHandle();
   if (parent.getCaret() == null) {
     parent.setCaret(this);
   }
 }
Пример #3
0
 void releaseParent() {
   super.releaseParent();
   if (this == parent.getCaret()) parent.setCaret(null);
 }