Bug 292056 - [StyledText] StyledText: add listener for direction change and allow to veto
Summary: [StyledText] StyledText: add listener for direction change and allow to veto
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Felipe Heidrich CLA
QA Contact: Felipe Heidrich CLA
URL:
Whiteboard:
Keywords:
Depends on: 291949
Blocks: 291950
  Show dependency tree
 
Reported: 2009-10-12 11:53 EDT by Dani Megert CLA
Modified: 2009-10-26 12:35 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-10-12 11:53:22 EDT
I20091006-0800.

FUP of 289752. 

In order to change the direction for all widgets inside the editor we need to have a listener for direction changes and it should be possible to veto the direction change in the event.
Comment 1 Felipe Heidrich CLA 2009-10-13 09:43:09 EDT
Do you need the event when the direction changes ?


Can you just use VerifyKeyListener to stop shift control  ?

My only problem here is to add an orientation change event to org.eclipse.swt.custom and later on need the same event in org.eclipse.swt.widgets (for Text/Combo).
Comment 2 Dani Megert CLA 2009-10-13 11:33:28 EDT
>Do you need the event when the direction changes ?
I think so, as for normal editors which don't hard-code LTR it makes sense to offer the functionality and hence we need a listener.
Comment 3 Markus Keller CLA 2009-10-13 14:01:48 EDT
> Do you need the event when the direction changes ?
Yes (but only at the point where there's no way back other than our veto, and we can be sure it's really changed).

> Can you just use VerifyKeyListener to stop shift control  ?
Not really, since StyledText#handleKeyDown(Event) does not copy keyLocation, and VerifyKeyListener#verifyKey(VerifyEvent) also doesn't mention the new field.

When I fix that and move the orientation switching code into
"if (verifyEvent.doit) { .. }", then "event.doit= false;" could work for vetoing. But it's not nice, since it adds a platform dependency, and we would need more hacks to find out whether the orientation really did change in the KeyUp event in the end. And it would probably be an issue for other key listeners in text editors (like hyperlinking modifiers).


> My only problem here is to add an orientation change event to
> org.eclipse.swt.custom and later on need the same event in
> org.eclipse.swt.widgets (for Text/Combo).

A new event on all 3 would definitely be nice, especially if it also helps solving bug 165089.
Comment 4 Felipe Heidrich CLA 2009-10-14 12:14:39 EDT
Okay, I can put the new event type up in SWT and have it working for Text/Combo/StyledText - only one windows with bidi enabled.
I verify it can be used to fix bug 165089.


The only problem is that Text and Combo can have the orientation changed by the native context menu, in which case the event is not send.

Spinner on windows also responds to Ctrl+(L R)Shift

SSQ, should we go ahead with this ?
Comment 5 Felipe Heidrich CLA 2009-10-14 13:49:36 EDT
Question: should the event be send when the orientation is changed programatically (via StyledText#setOrientation) ?
Keep in mind, event.doit=false stops the operation.
Comment 6 Markus Keller CLA 2009-10-14 14:39:01 EDT
> should the event be send when the orientation is changed programatically?

I'd say no, that's a "normal" event as described in
http://www.eclipse.org/swt/faq.php#noeventfire
Comment 7 Silenio Quarti CLA 2009-10-14 17:49:14 EDT
(In reply to comment #3)
> Not really, since StyledText#handleKeyDown(Event) does not copy keyLocation,
> and VerifyKeyListener#verifyKey(VerifyEvent) also doesn't mention the new
> field.

We should fix this. I beleive CCombo also have the problem.
Comment 8 Felipe Heidrich CLA 2009-10-15 09:30:58 EDT
(In reply to comment #7)
> (In reply to comment #3)
> > Not really, since StyledText#handleKeyDown(Event) does not copy keyLocation,
> > and VerifyKeyListener#verifyKey(VerifyEvent) also doesn't mention the new
> > field.
> We should fix this. I beleive CCombo also have the problem.

Fix VerifyKey for StyledText, and all events for CCombo too.
Comment 9 Felipe Heidrich CLA 2009-10-16 10:39:55 EDT
Fixed in HEAD > 20091016

See SWT.OrientationChange
The event is sent for Text, Combo, StyledText.
The event is sent before the change, so the application has the chance to set doit to false to stop the change from happening.

The event is only send when the change is caused by keyboard shortcut. 
Orientation can still be changed programatically -without any event being sent- on Text, Combo, and StyledText (see setOrientation()).
For Text, Combo the orietation can also be changed via the native context menu (no event sent either).