Paint Event triggered by Verify Event [message #693134] |
Tue, 05 July 2011 21:31 |
|
How can I trigger a paint event when handling a verify event? for instance if the content of a text box "becomes" longer than N characters I want to draw a red line along the margins of the text box.
I know how to use the VerifyEvent and the PaintEvent but I do not know how to link them. I probably miss something very simple, but I cannot figure out what.
The events are bellow:
textDescription.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
if (event.doit == false) {
// event already consumed
return;
}
if (textDescription.getText().length() > DESC_LENGTH) {
// show the field decorator
dec.show();
event.doit = false;
if (event.character == '\u0008' || event.character == '\u007F') {
// allow delete and/or backspace to be processed
event.doit = true;
}
} else {
// hide the field decorator
dec.hide();
}
}
});
textDescription.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent evt) {
Point s = textDescription.getSize();
Color c = evt.gc.getForeground();
evt.gc.setForeground(textDescription.getDisplay().getSystemColor(
SWT.COLOR_RED));
evt.gc.drawRectangle(0, 0, s.x - 5, s.y - 5);
evt.gc.setForeground(c);
}
});
Any help would be appreciated.
Time is what you make of it.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03511 seconds