Author Topic: Drag from PB and drop in custom tab control  (Read 4916 times)

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Drag from PB and drop in custom tab control
« on: April 23, 2015, 09:49:53 pm »
Hi guys,

I would like to drag an item from the project browser onto a homemade tab control. I have included a panel to react to the drop event and when I run this in a windows forms application it works fine.

But, inside EA it appears that EA interferes with the drag and drop action (obviously). So, I can select an item, e.g. a use case and start dragging it, but when I drop it over my drop-enabled panel EA displays a message box saying "There is no current diagram to perform this operation. Please select a diagram first."

Any ideas of how to capture the drop in my code without EA bothering about it?

Cheers
Knut


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Drag from PB and drop in custom tab control
« Reply #1 on: April 23, 2015, 10:13:57 pm »
I don't think you can, but I've never tried.

Geert

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Drag from PB and drop in custom tab control
« Reply #2 on: April 24, 2015, 02:03:24 am »
I have a hunch that the EA UI and your tab control could be in different threads. I had some issues with some of my code doing something similar i.e. EA UI and my own tab control, and getting cross-thread exceptions being thrown.  

I did look around at the time for solutions but the problem I saw was getting into the EA UI code, not least as I needed to understood what object was being dropped.

From memory one approach I looked at was to:
1. Track the selected item using context change events
and
2. Have some windows graphics code intercept all mouse events, catching the release of mouse events, and checking if the coordinates were in my window.  

In the end it wasn't nice so gave up on it - but if you find a reliable solution please let us know.

A further thought I had after posting my initial response.  Unless EA provides a mechanism to let you "take the element" and let you tell EA that you have handled the event, as some addin events support, you will still get the unwanted message about not dropping on a diagram.  

« Last Edit: April 24, 2015, 05:13:50 am by MrWappy »
EXploringEA - information, utilities and addins

L.Krobot

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Drag from PB and drop in custom tab control
« Reply #3 on: May 04, 2015, 12:06:09 am »
If you have open a diagram (any diagram), this will work as long as you have active your form, and you are dropping the element on the diagram ...
basically, you should have a diagram opened and on the top of it your form, so when you drag element from the browser to the your control in the form (and open diagram in background), your user will have a filling that element has been dropped into your control (form) ...
if you do not have a open diagram, you could try (on start drag event) create and open on the fly a new diagram (that would enable you to avoid nasty message), and when you drop the element (on end drag event), just close and delete a temporary diagram ....
if you find better solution, let us know ...
rgrds.

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: Drag from PB and drop in custom tab control
« Reply #4 on: May 05, 2015, 08:28:50 pm »
Have you tried this? I get the same complaint from EA about the missing diagram even thought there is an open diagram 'below' my control.

br
Knut