Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Paint Event triggered by Verify Event
Paint Event triggered by Verify Event [message #693134] Tue, 05 July 2011 21:31 Go to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

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.
Re: Paint Event triggered by Verify Event [message #693953 is a reply to message #693134] Thu, 07 July 2011 14:27 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

You could call Text.redraw() inside the VerifyListener and see if SWT.Paint event is sent.


Lakshmi P Shanmugam
Re: Paint Event triggered by Verify Event [message #694145 is a reply to message #693953] Thu, 07 July 2011 22:35 Go to previous message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Lakshmi

Indeed calling Text.redraw() activated the Paint event. As I said it was something very simple Embarrassed

Thank you for your quick response.


Time is what you make of it.
Previous Topic:help to execute .jar in console
Next Topic:GC Can Not DrawFocus On Window 7 64Bit
Goto Forum:
  


Current Time: Tue Apr 23 06:22:43 GMT 2024

Powered by FUDForum. Page generated in 0.02951 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top