Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] StyledText and keyboard actions

Hi all,

The code of StyledText.handleKeyDown (the method that sends the VerifyKey event) looks like this (shortened by irrelevant parts):

	event.stateMask &= SWT.MODIFIER_MASK;

	Event verifyEvent = new Event();
	verifyEvent.character = event.character;
	verifyEvent.keyCode = event.keyCode;
	verifyEvent.keyLocation = event.keyLocation;
	verifyEvent.stateMask = event.stateMask;
	verifyEvent.doit = event.doit;
	notifyListeners(ST.VerifyKey, verifyEvent);
	if (verifyEvent.doit) {
		if ((event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL && event.keyCode == SWT.SHIFT && isBidiCaret()) {
			newOrientation = event.keyLocation == SWT.LEFT ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT;
		}
		handleKey(event);
	}

The problem is that if the VerifyKey-listener has set verifyEvent.doit to false, this change is NOT propageted to the KeyDown listener, so if there is one more KeyDown listener, it will not know whether the event already has been processed. Looks like a bug to me.

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://www.syntevo.com/blog


On 2017-02-02 21:27, Gunnar Wagenknecht wrote:
Hi Thomas,

Have a look at AbstractTextEditor#createNavigationActions. It sounds like it does what you are looking for.

It does:
textWidget.setKeyBinding(SWT.INSERT, SWT.NULL);

And hooks its own VerifyKeyListener and matches keys to actions.

-Gunnar



Back to the top