Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top