Right Click Cell Table

614 views
Skip to first unread message

John Maitland

unread,
Dec 9, 2011, 6:02:45 AM12/9/11
to Google Web Toolkit
Is it possible that on right click, that the cell is also selected?

If I sink ONCONTEXTMENU, it will provide a context menu event, which
won't render the cell selected. For the cell to be selected, I need a
click event from the cell itself.

Many thanks,

John

Thomas Broyer

unread,
Dec 9, 2011, 6:18:06 AM12/9/11
to google-we...@googlegroups.com
I think you need a CellPreviewEvent.Handler (have a look at DefaultEventSelectionManager) so that a "contextmenu" event turns into a SelectAction.SELECT or SelectAction.TOGGLE (depending on whether the Ctrl or Meta key is down). The current code should correctly change selection on a "click" event, whichever the button (left, right or middle).
Or maybe your cell is handling selection itself? (isSelectionHandled returns true)

John Maitland

unread,
Dec 9, 2011, 7:43:17 AM12/9/11
to Google Web Toolkit
So put the contextmenu event on the cell itself rather than sinking an
event on the celltable?

John

Thomas Broyer

unread,
Dec 9, 2011, 8:40:42 AM12/9/11
to google-we...@googlegroups.com
No, CellPreviewEvent.Handler runs for every event of the CellTable, targetting any of its cells; so you'd sink the contextmenu at the CellTable level, and handle it from the CellPrevewEvent.Handler (or in your case probably a DefaultSelectionEventManager.EventTranslator passed to DefaultSelectionEventManager.createCustomManager())

John Maitland

unread,
Dec 9, 2011, 9:25:04 AM12/9/11
to Google Web Toolkit
Thanks, all works! I already have a custom
DefaultSelectionEventManager for double clicking. I had to override
handleMultiSelectionEvent as it only works for click and keyup
explicitly. A single selection model would work as is.
Reply all
Reply to author
Forward
0 new messages