Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Finding what is under the cursor in context popup
Finding what is under the cursor in context popup [message #771982] Wed, 28 December 2011 12:56 Go to next message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
I have a context menu in a TreeView. This menu has a item to create a new tree node.
When the Handler gets called from the menu, I can get the ISelection and get the selected node in the tree.
So this lets me create child nodes just fine.
The problem is when I want to create a new node off the root.
i.e. Right-click in blank area at bottom of tree.
The selection doesn't change, so I can't use selection.

How do I determine that the right-click happened over no node?

Re: Finding what is under the cursor in context popup [message #772202 is a reply to message #771982] Thu, 29 December 2011 03:27 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5262
Registered: July 2009
Senior Member
Use the current cursor location on the screen, calculate it back to the
Tree using toControl() and then call viewer.getCell(int,int) if this
return null you have clicked in an empty area.

Still your current appoarch has problem: What happens if there's no
empty area anymore? I'd suggest you always show an "Add Root" and "Add
Child".

Tom

Am 28.12.11 18:56, schrieb Cougar:
> I have a context menu in a TreeView. This menu has a item to create a
> new tree node.
> When the Handler gets called from the menu, I can get the ISelection and
> get the selected node in the tree.
> So this lets me create child nodes just fine.
> The problem is when I want to create a new node off the root.
> i.e. Right-click in blank area at bottom of tree.
> The selection doesn't change, so I can't use selection.
>
> How do I determine that the right-click happened over no node?
>
>
Re: Finding what is under the cursor in context popup [message #772382 is a reply to message #772202] Thu, 29 December 2011 11:40 Go to previous message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
Thanks, and yes I see problem if there isn't any blank space.
Though having "Add new Child", and "Add new Root" menu items seems kind of klunky as well.
I do have Drag and Drop working, so the user could drag it back to the root, but that's klunky as well.

Other suggestions?
Previous Topic:Adding a new command action
Next Topic:Project Explore/Package Explore question
Goto Forum:
  


Current Time: Sat Aug 02 04:42:53 EDT 2014

Powered by FUDForum. Page generated in 0.01995 seconds