use of org.eclipse.swt.custom.CaretListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_custom_StyledText method test_addCaretListener_CaretListenerCalled.
@Test
public void test_addCaretListener_CaretListenerCalled() {
listenerCalled = false;
CaretListener listener = event -> listenerCalled = true;
text.setText("Line1");
text.addCaretListener(listener);
text.setCaretOffset(1);
assertTrue("Listener not called", listenerCalled);
}
use of org.eclipse.swt.custom.CaretListener in project otertool by wuntee.
the class CTabItemWithHexViewer method addListeners.
private void addListeners(final StyledText txt) {
txt.addMouseWheelListener(new MouseWheelListener() {
public void mouseScrolled(MouseEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
txt.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
public void widgetSelected(SelectionEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
txt.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
txt.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
txt.addCaretListener(new CaretListener() {
public void caretMoved(CaretEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
txt.addDragDetectListener(new DragDetectListener() {
public void dragDetected(DragDetectEvent arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
ScrollBar vbar = txt.getVerticalBar();
if (vbar != null) {
vbar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
binContent.setTopIndex(txt.getTopIndex());
hexContent.setTopIndex(txt.getTopIndex());
counter.setTopIndex(txt.getTopIndex());
}
});
}
}
use of org.eclipse.swt.custom.CaretListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_custom_StyledText method test_removeCaretListener_CaretListenerNotCalled.
@Test
public void test_removeCaretListener_CaretListenerNotCalled() {
listenerCalled = false;
CaretListener listener = event -> listenerCalled = true;
text.addCaretListener(listener);
text.removeCaretListener(listener);
text.setCaretOffset(1);
assertFalse("Listener not removed", listenerCalled);
}
use of org.eclipse.swt.custom.CaretListener in project watchdog by TestRoots.
the class EditorListener method listenToEditorScrolling.
private void listenToEditorScrolling() {
styledText = (StyledText) editor.getAdapter(Control.class);
if (styledText == null) {
return;
}
// creates a listener for when the user moves the caret (cursor)
caretListener = new CaretListener() {
@Override
public void caretMoved(CaretEvent event) {
WatchDogEventType.CARET_MOVED.process(editor);
// cursor place changed
}
};
styledText.addCaretListener(caretListener);
// creates a listener for redraws of the view, e.g. when scrolled
paintListener = new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
WatchDogEventType.PAINT.process(editor);
}
};
styledText.addPaintListener(paintListener);
focusListener = new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
}
@Override
public void focusGained(FocusEvent e) {
WatchDogEventType.ACTIVE_FOCUS.process(editor);
}
};
styledText.addFocusListener(focusListener);
}
Aggregations