Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Get keyboard modifiers (stateMask) on dragStart() ?
Get keyboard modifiers (stateMask) on dragStart() ? [message #443500] Sat, 25 September 2004 17:37 Go to next message
Jelle Herold is currently offline Jelle HeroldFriend
Messages: 42
Registered: July 2009
Member
Hi,

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.

Thanks for the help,
Jelle.
--
http://defekt.nl/
http://www.students.cs.uu.nl/people/jherold/
Re: Get keyboard modifiers (stateMask) on dragStart() ? [message #443787 is a reply to message #443500] Thu, 30 September 2004 15:13 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
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?

"Jelle Herold" <jelle@defekt.nl> wrote in message
news:cj4adi$oil$1@eclipse.org...
> Hi,
>
> 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.
>
> Thanks for the help,
> Jelle.
> --
> http://defekt.nl/
> http://www.students.cs.uu.nl/people/jherold/
Re: Get keyboard modifiers (stateMask) on dragStart() ? [message #443841 is a reply to message #443787] Sun, 03 October 2004 00:06 Go to previous message
Jelle Herold is currently offline Jelle HeroldFriend
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/
Previous Topic:Stay on top shell
Next Topic:How to create dynamic forms in SWT
Goto Forum:
  


Current Time: Fri Sep 20 11:17:26 GMT 2024

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

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

Back to the top