Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Pasting Near The Mouse Pointer
Pasting Near The Mouse Pointer [message #658701] Wed, 09 March 2011 14:27 Go to next message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
When a user pastes I'd like to be able to place the graphical objects relative to the current position of the mouse pointer. The IPasteContext does not contain coordinates for the pointer when the paste operation was invoked, so at the moment I'm limited to whatever information I pass through the clipboard from the original copy operation. That allows me to perform the paste at an offset relative to the original, but that may be meaningless if the paste operation is performed in another diagram.

Is that a feature I should request? Or is there some mechanism for getting the mouse pointer coordinates that I'm missing?
Re: Pasting Near The Mouse Pointer [message #658731 is a reply to message #658701] Wed, 09 March 2011 15:50 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Rhett,

you can try a hack. Use

ILocation mouseLocation = ((DiagramEditorInternal)
getDiagramEditor()).getCurrentMouseLocation();

to retrieve the current mouse location. Unfortunately, this introduces a
dependency to gef
in your coding and also an internal usage since DiagramEditorInternal is
obviously internal ;-).
So it is really a hack just to try if you could get things working as
desired.

So either we could streamline the API of IDiagramEditor or we could
add the coordinates to the context (which is better from my point of view).
If we add coordinates to the context we should express them
container-relative...

What do you think?

Best, Tim
Re: Pasting Near The Mouse Pointer [message #658743 is a reply to message #658731] Wed, 09 March 2011 16:23 Go to previous messageGo to next message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
Tim,

I agree with your opinion that passing the coordinates through the context is better. I haven't seen anywhere else in the Graphiti framework where the user in encouraged to randomly sample the position of the mouse. Smile Though I may temporarily try your suggested hack to make my paste a little nicer.

In terms of passing relative coordinates, I'm not sure what the container is in this case. The Diagram that contains the PictogramElements in the array held by the IPasteContext? That seems fine. It might be nice for the IPasteContext to actually have a reference to the Diagram that contains the PictogramElements in the array.

The example code requires that the Diagram be selected to do a paste, but I didn't like the additional click required to deselect the things I had just selected for copying in order to do the paste. So, my canPaste() and my paste() have some additional complexity for digging the Diagram out of whatever shows up in the PictogramElement array.

--Rhett
Re: Pasting Near The Mouse Pointer [message #658922 is a reply to message #658743] Thu, 10 March 2011 13:06 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Can you open a bugzilla for your requirement?
Re: Pasting Near The Mouse Pointer [message #658944 is a reply to message #658922] Thu, 10 March 2011 14:31 Go to previous message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
Done, it is Bug 339525.
Previous Topic:ToolBar DropDown Menu for Graphiti Based Editor
Next Topic:How to overlay images
Goto Forum:
  


Current Time: Thu Apr 18 14:49:22 GMT 2024

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

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

Back to the top