Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to disable key binding Ctrl+i in StyledText control
How to disable key binding Ctrl+i in StyledText control [message #542486] Fri, 25 June 2010 05:12 Go to next message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi,

I want to trigger the Italic style in StyledText control when user click ctrl+i, but there is an action binding with Ctrl+i by default(tab key).

How to disable it, the following code seems not work well.

StyledText widget = new StyledText(shell, SWT.BORDER);
widget.setText("This is the StyledText widget.");
widget.setKeyBinding(SWT.CTRL | 'i', SWT.NULL);

Thanks.
Re: How to disable key binding Ctrl+i in StyledText control [message #542619 is a reply to message #542486] Fri, 25 June 2010 13:12 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

StyledText doesn't have a default key binding for Ctrl + i. You can verify this by doing widget.getKeyBinding(SWT.CTRL|'i'), it returns 0.
What you are seeing is a feature of the platform which causes the <Ctrl>+i combination to be translated into TAB.
You can add a VerifyKeyListener to the StyledText widget to disable this behavior.

widget.addVerifyKeyListener(new VerifyKeyListener() {
		public void verifyKey(VerifyEvent event) {
			if (event.keyCode == 'i' && event.stateMask == SWT.CTRL){
				event.doit = false;
			}
		}
}


Lakshmi P Shanmugam
Re: How to disable key binding Ctrl+i in StyledText control [message #542962 is a reply to message #542619] Mon, 28 June 2010 01:29 Go to previous message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi Lakshmi,

It works fine, thanks for your suggestion.

lushiwei
Previous Topic:Setting visible items count in Combo dynamically
Next Topic:flickering virtual table rows
Goto Forum:
  


Current Time: Wed Apr 24 17:32:05 GMT 2024

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

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

Back to the top