multiple selection on the Mac

45 views
Skip to first unread message

boscomonkey

unread,
Aug 8, 2007, 7:22:12 PM8/8/07
to gwt-dnd
Fred, here's the latest progress regarding multiple selection.

I'm using EventPreview to trap click events on draggables and query
the keyboard to determine whether it's a "toggle-click" (i.e., ctrl-
click) or "extend-click" (i.e., shift-click). The standard click event
doesn't expose the Event object and thus I couldn't call
KeyboardListenerCollection.getKeyboardModifiers to get the modifier
bit vector.

Dragging & Dropping of multiply selected items in an IndexedFlowPanel
works nicely on Windows with IE and Firefox. However, I'm stuck on the
Macintosh.

The convention on the Mac is that "toggle-click" is performed with the
Command Key (a.k.a., Apple Key or clover key). However, I can't figure
out how to detect the Command Key.

Any suggestions?

-- Bosco

Fred Sauer

unread,
Aug 8, 2007, 7:40:22 PM8/8/07
to gwt...@googlegroups.com
Bosco,

How did you do it in the IE/Firefox case? Assuming there are no 'modifier' bits for you to access, you could setup a global onkeydown/press listener (depending on what detects the command key). I proposed a starting point in this thread:
  http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/81a327119c6dde52/5eada93ab726cb51?#5eada93ab726cb51

Also, I should note that GWT 1309 provides access to the current event object, in case you hadn't seen that yet:
   http://code.google.com/p/google-web-toolkit/issues/detail?id=1309

Fred

On 8/8/07, boscomonkey <bosco...@gmail.com> wrote:

Fred, here's the latest progress regarding multiple selection.

I'm using EventPreview to trap click events on draggables and query
the keyboard to determine whether it's a "toggle-click" ( i.e., ctrl-

boscomonkey

unread,
Aug 8, 2007, 8:01:01 PM8/8/07
to gwt-dnd
The EventPreview is very similar in style to a global onkeydown/press
listener. Except that I'm just looking at clicks (instead of key
events) and checking for keyboard modifier. This seemed to be easier
than keeping track of keydowns/ups and detecting clicks.

In the IE/Firefox case, the EventPreview interface had full access to
the Event object and thus I could call
KeyboardListenerCollection.getKeyboardModifiers(Event) to get a bit
vector of the keyboard modifiers. I'm testing for
KeyboardListener.MODIFIER_META but the Mac Command key isn't
triggering it.

-- Bosco


On Aug 8, 4:40 pm, "Fred Sauer" <f...@allen-sauer.com> wrote:
> Bosco,
>
> How did you do it in the IE/Firefox case? Assuming there are no 'modifier'
> bits for you to access, you could setup a global onkeydown/press listener
> (depending on what detects the command key). I proposed a starting point in
> this thread:
>

> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...


>
> Also, I should note that GWT 1309 provides access to the current event
> object, in case you hadn't seen that yet:
> http://code.google.com/p/google-web-toolkit/issues/detail?id=1309
>
> Fred
>

> On 8/8/07, boscomonkey <boscomon...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Fred, here's the latest progress regarding multiple selection.
>
> > I'm using EventPreview to trap click events on draggables and query

> > the keyboard to determine whether it's a "toggle-click" (i.e., ctrl-


> > click) or "extend-click" (i.e., shift-click). The standard click event
> > doesn't expose the Event object and thus I couldn't call
> > KeyboardListenerCollection.getKeyboardModifiers to get the modifier
> > bit vector.
>
> > Dragging & Dropping of multiply selected items in an IndexedFlowPanel
> > works nicely on Windows with IE and Firefox. However, I'm stuck on the
> > Macintosh.
>
> > The convention on the Mac is that "toggle-click" is performed with the
> > Command Key (a.k.a., Apple Key or clover key). However, I can't figure
> > out how to detect the Command Key.
>
> > Any suggestions?
>
> > -- Bosco
>

> --
> Fred Sauer
> f...@allen-sauer.com- Hide quoted text -
>
> - Show quoted text -

Fred Sauer

unread,
Aug 8, 2007, 9:34:16 PM8/8/07
to gwt...@googlegroups.com
Bosco,

From what I can tell, KeyboardListenerCollection uses DOM.eventGetMetaKey(event) which uses DOMImpl to check event.metaKey. That all appears to be correct (based on some online references), although I don't have a mac to test on.

Fred


On 8/8/07, boscomonkey <bosco...@gmail.com> wrote:

The EventPreview is very similar in style to a global onkeydown/press
listener. Except that I'm just looking at clicks (instead of key
events) and checking for keyboard modifier. This seemed to be easier
than keeping track of keydowns/ups and detecting clicks.

In the IE/Firefox case, the EventPreview interface had full access to
the Event object and thus I could call
KeyboardListenerCollection.getKeyboardModifiers (Event) to get a bit

boscomonkey

unread,
Aug 9, 2007, 4:15:56 PM8/9/07
to gwt-dnd
Just found the problem. It's a bug with GWT (1.4.10). Their
implementation of DOM.eventGetMetaKey(event) is

public native boolean eventGetMetaKey(Event evt) /*-{
return !!evt.getMetaKey;
}-*/;

Whereas if I change it to

public native boolean eventGetMetaKey(Event evt) /*-{
return evt.metaKey ? true : false;
}-*/;

Then, the meta key shows up. Grrrrrr.

-- Bosco


On Aug 8, 6:34 pm, "Fred Sauer" <f...@allen-sauer.com> wrote:
> Bosco,
>

> From what I can tell, KeyboardListenerCollection uses
> DOM.eventGetMetaKey(event)
> which uses DOMImpl to check event.metaKey. That all appears to be correct
> (based on some online references), although I don't have a mac to test on.
>
> Fred
>

> On 8/8/07, boscomonkey <boscomon...@gmail.com> wrote:
>
>
>
>
>
>
>
> > The EventPreview is very similar in style to a global onkeydown/press
> > listener. Except that I'm just looking at clicks (instead of key
> > events) and checking for keyboard modifier. This seemed to be easier
> > than keeping track of keydowns/ups and detecting clicks.
>
> > In the IE/Firefox case, the EventPreview interface had full access to
> > the Event object and thus I could call

> > KeyboardListenerCollection.getKeyboardModifiers(Event) to get a bit

boscomonkey

unread,
Aug 9, 2007, 4:37:59 PM8/9/07
to gwt-dnd
Actually, the

!!evt.metaKey

construct works. It's just that GWT had a typo

!!evt.getMetaKey

> > > > > Any suggestions?- Hide quoted text -

boscomonkey

unread,
Aug 9, 2007, 8:04:11 PM8/9/07
to gwt-dnd
This is a known issue - GWT 1118

http://code.google.com/p/google-web-toolkit/issues/detail?id=1118

> > - Show quoted text -- Hide quoted text -

sche...@opto22.com

unread,
Mar 28, 2014, 4:49:54 PM3/28/14
to gwt...@googlegroups.com
Hi guys.  I am new to this group and it seems that this is the appropriate topic for my issue.

Fred,

First off, thank you for producing this library and making it open source.  Second, while working with multiple selection (and my affected context menu code), I came across an issue where I could not select multiple objects on a Mac by holding down [Shift] and clicking the objects.  I finally tracked down the problem to the method "private boolean toggleKey(~)" in MouseDragHandler.java.  The original source code is as follows:

private boolean toggleKey(HumanInputEvent<?> event)
{
return event.isControlKeyDown() || event.isMetaKeyDown();
}

In the case of a Mac, it is the Shift key that we want to check on so I modified the code as follows:

private boolean toggleKey(HumanInputEvent<?> event)
{
return (Sniffers.isMac() ? event.isShiftKeyDown() : event.isControlKeyDown()) || event.isMetaKeyDown();
}

where Sniffers.isMac() is:

public static native boolean isMac() /*-{
return navigator.appVersion.indexOf("Mac") != -1;
}-*/;

I have done minimal testing but making this change solves the issue on my MacbookPro and the behavior on my Windows machine remains unchanged.  Please let me know if you have come across any issues where this might have undesirable affects.  Thanks.
Reply all
Reply to author
Forward
0 new messages