예제 #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);
 }