|
|
Re: Get keyboard modifiers (stateMask) on dragStart() ? [message #443841 is a reply to message #443787] |
Sun, 03 October 2004 00:06 |
Jelle Herold Messages: 42 Registered: July 2009 |
Member |
|
|
On 2004-09-30, Veronika Irvine <veronika_irvine@oti.com> wrote:
> > Is it possible to get the current keyboard mask in
> > DragSourceListener.dragStart(DragSourceEvent event)? Depending on
> > the state of the Control-key I want to either allow or disallow
> > (using event.doit = true/false) a drag operation.
>
> The keyboard mask is not available but usually what an application does is
> define the allowed operations and this will reflect the keyboard mask.
>
> For example, on Windows
>
> Copy = Ctrl
> Move = Shift
> Link = Ctrl+Shift
>
> Disallowing the drag in the dragStart based on keyboard modifiers is not
> typically useful because the user can release the key while dragging or
> press another key while dragging.
>
> What are you trying to do here?
(I've found the solution for my problem while writing this, but i'm
posting anyway in case this is usefull for anyone else.)
I've got a composite "Timeline" widget, looking somewhat like this:
+------------------+
| +---+ +-------+ |
|c| a |c| b |cc|
| +---+ +-------+ |
+------------------+
It contains two boxes (Events) (a, b) that can be dragged in horizontal
position (to a, b or one of c). It should also be possible to drag the
entire widget somewhere else.
The boxes can be dropped in two ways, lets say "fit" and "move" (this
determines the position and size of the box after the drop).
So, I need to distinguish what is dragged ("box" or "widget") on drag start
and again distinguish between how it is dropped ("fit" or "move").
OK. The solution for this "problem" coming in the form of a toolkit (the
State pattern[1]): change the default drag tool (drag_event or
drag_timline) if the ctrl key is pressed. The drop type can then be
discovered by swt's DND type (Move, Link, Copy).
Another note: I've implemented some drag-like mouse behaviour based on
MouseListeners for a custom widget. In addition I'm using swt's dnd
mechanism to drag the entire widget to a table. However, this makes it
hard to use the State pattern. Therefor it should be removed in
favour of using swt's dnd mechanism.
Hope this is of any use...
Jelle
[1] Some info on the State pattern
http://home.earthlink.net/~huston2/dp/state.html
http://c2.com/cgi/wiki?StatePattern
--
http://defekt.nl/
http://www.students.cs.uu.nl/people/jherold/
|
|
|
Powered by
FUDForum. Page generated in 0.03839 seconds