Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Handling enter pressed on TableEditor


Try using Display.asyncExec() to run your key pressed code after the text control has processed the key.  That should fix your problem.



Vinicius Carvalho <java.vinicius@xxxxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

06/13/2005 10:01 AM

Please respond to
Vinicius Carvalho and "Eclipse Platform SWT component developers list."

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] Handling enter pressed on TableEditor





Hello there! I'm a newbie on SWT. I have a table, where a column is
filled with Texts so the user can edit it. What I'd like to do is
after the user press enter button the item on the table gets updated.
I tried this:
text.addKeyListener(new KeyAdapter(){
                                         public void keyPressed(KeyEvent e) {
                   if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                  // fancy code ;)
                   }
                                         }
                        });

Well, from KeyEvent, I do have access to the source (the Text object)
but how do I access the item? I also tried:
text.addModifyListener(new ModifyListener(){
                                         public void modifyText(ModifyEvent e){
                                         //fancy code
                                         }
                        });

this time I can access the item, but it's called on every key press,
and I can't figure out when the user pressed enter, so I could
surround it by an if block.

Any suggestions?

Regards Vinicius
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top