Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Capture key state when tool is selected in Palette?
Capture key state when tool is selected in Palette? [message #644452] Sat, 11 December 2010 15:52 Go to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Is there any way to query whether the Shift key is depressed when a tool
is selected in a Palette? Basically, I want to know if a key is pressed
at the point of activating the tool.

I've got a custom Tool that extends AbstractTool but can't seem to find
a way to query the key state when activate() is called on the tool.

Thanks,

PB
Re: Capture key state when tool is selected in Palette? [message #644464 is a reply to message #644452] Sat, 11 December 2010 17:32 Go to previous message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 11/12/2010 15:52, Phillipus wrote:
> Is there any way to query whether the Shift key is depressed when a tool
> is selected in a Palette? Basically, I want to know if a key is pressed
> at the point of activating the tool.
>
> I've got a custom Tool that extends AbstractTool but can't seem to find
> a way to query the key state when activate() is called on the tool.
>
> Thanks,
>
> PB

I did it another way. I added a listener in my GraphicalEditor:


getEditDomain().getPaletteViewer().getControl().addMouseList ener(new
MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
EditPart ep =
getEditDomain().getPaletteViewer().findObjectAt(new Point(e.x, e.y));
if(ep != null && ep.getModel() instanceof ToolEntry) {
ToolEntry tool = (ToolEntry)ep.getModel();
if(tool != null) {
boolean shiftKey = (e.stateMask & SWT.SHIFT) != 0;

tool.setToolProperty(AbstractTool.PROPERTY_UNLOAD_WHEN_FINIS HED, !shiftKey);
}
}
}
});
Previous Topic:Problem with TextFlow clipping text on Zoom
Next Topic:draw2d interaction sequence
Goto Forum:
  


Current Time: Sat Dec 20 14:34:43 GMT 2014

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

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