Drag-and-Drop Trigger Events From Objects to Objects

I would like to run some DXL after a drag-and-drop event (e.g. a copy objects operation) between objects in a formal module.  This DXL needs info about objects dragged and the object that is the target of the "drop". I have no troubles getting the drag info.  However, "drop" trigger does not appear to fire upon a "drop" within same instance of DOORS.

Side note: the drop event does fire, upon drag and drop between module objects opened via two different instances of DOORS but this doesn't meet my need.

I would very much appreciate ideas on an approach that might meet my objective.

 


BobSherman - Sun Aug 23 14:00:48 EDT 2015

Re: Drag-and-Drop Trigger Events From Objects to Objects
pommCannelle - Mon Aug 24 06:08:27 EDT 2015

The drop event is not designed to work as you expect ;) Have a look in the help - > "Triggered when data is dragged from another application and dropped onto a displayed formal module object"

But you can:
- use the popup menu the add a function to launch when drop ... but this is not the sublect of this topic ;)
- use the sync trigger to catch the change of the current object as drop traget ... 
Here after a quick start ;) 
 

void code_post_trigger(Trigger t){
    Object o = object(t)
    if (null o) return
    oleSetResult( probeAttr_(o, "absolute number") "" )
}

void code_post_sync(Trigger t){
    Object o = object(t)
    if (null o) return
    string sourceObjID = oleGetResult()
    if (sourceObjID"" == "" ) return
    print "Getting data from " sourceObjID " into " probeAttr_(o, "absolute number") "\n"
    oleSetResult("")
}

Trigger t = trigger(project->module->"/ESPACE TEST DOORS/pommCannelle/essai 3"->object, drag, 5, code_post_trigger )

if ( ! null t) log "trigger on the drag OK\n"
else log "trigger on the drag NOK\n"

t = trigger(project->module->"/ESPACE TEST DOORS/pommCannelle/essai 3"->object, sync, 5, code_post_sync )

if ( ! null t) log "trigger on the sync OK\n"
else log "trigger on the sync NOK\n"

 

Re: Drag-and-Drop Trigger Events From Objects to Objects
BobSherman - Mon Aug 24 07:34:39 EDT 2015

pommCannelle - Mon Aug 24 06:08:27 EDT 2015

The drop event is not designed to work as you expect ;) Have a look in the help - > "Triggered when data is dragged from another application and dropped onto a displayed formal module object"

But you can:
- use the popup menu the add a function to launch when drop ... but this is not the sublect of this topic ;)
- use the sync trigger to catch the change of the current object as drop traget ... 
Here after a quick start ;) 
 

void code_post_trigger(Trigger t){
    Object o = object(t)
    if (null o) return
    oleSetResult( probeAttr_(o, "absolute number") "" )
}

void code_post_sync(Trigger t){
    Object o = object(t)
    if (null o) return
    string sourceObjID = oleGetResult()
    if (sourceObjID"" == "" ) return
    print "Getting data from " sourceObjID " into " probeAttr_(o, "absolute number") "\n"
    oleSetResult("")
}

Trigger t = trigger(project->module->"/ESPACE TEST DOORS/pommCannelle/essai 3"->object, drag, 5, code_post_trigger )

if ( ! null t) log "trigger on the drag OK\n"
else log "trigger on the drag NOK\n"

t = trigger(project->module->"/ESPACE TEST DOORS/pommCannelle/essai 3"->object, sync, 5, code_post_sync )

if ( ! null t) log "trigger on the sync OK\n"
else log "trigger on the sync NOK\n"

 

You delivered a solution that work perfectly for what I described.  Thanks very much for that!   However, I must apologize because I see now that my post/request did not include a key requirement.  That requirement is that I must also be able to generate the events when dragging objects between modules.  Further, in this case the destination object for the "drop" could be the same object upon two consecutive different (difference sources) "drag" events; thus the sync trigger would not fire in this case.  Example:
1) user drags obj1 in mod1 to obj3 in mod3
2) user drags obj2 in mod1 to obj3 in mod3

Re: Drag-and-Drop Trigger Events From Objects to Objects
pommCannelle - Mon Aug 31 04:44:38 EDT 2015

BobSherman - Mon Aug 24 07:34:39 EDT 2015

You delivered a solution that work perfectly for what I described.  Thanks very much for that!   However, I must apologize because I see now that my post/request did not include a key requirement.  That requirement is that I must also be able to generate the events when dragging objects between modules.  Further, in this case the destination object for the "drop" could be the same object upon two consecutive different (difference sources) "drag" events; thus the sync trigger would not fire in this case.  Example:
1) user drags obj1 in mod1 to obj3 in mod3
2) user drags obj2 in mod1 to obj3 in mod3

Hi ! 

I'm afraid you have to add a click to do what you need ;)
The fact is that the sync event seems to have the module as scope. So each module have is own sync event and select obj2 in mod1 should not reset the event in mod3... and i can't see any way to reset the event using dxl. (Perhaps some expert in the forum ... )
So  ... hereafter the solutions i can imagine :
- if you want to stay in the trigger way, the user just have to click another object in mod3 to reset the sync event ...not always easy with big objects ;)
- you can add the drop script in the contextual menu of mod3 to 'allow' the drop ... the contextual menu is firing when you drop -> seems to be the best way to do it ! 
- you can add a GUI able to store all the source objects and then to do the drop part in a second time (just a list with 2 buttons ... no big deal)
- you can use an other app to simulate a click every xxx millisecond in order to reset the sync event (no ... this one is not real ;D)

 

Feel free to post your code if you are in trouble ;)

Re: Drag-and-Drop Trigger Events From Objects to Objects
BobSherman - Mon Aug 31 09:16:58 EDT 2015

pommCannelle - Mon Aug 31 04:44:38 EDT 2015

Hi ! 

I'm afraid you have to add a click to do what you need ;)
The fact is that the sync event seems to have the module as scope. So each module have is own sync event and select obj2 in mod1 should not reset the event in mod3... and i can't see any way to reset the event using dxl. (Perhaps some expert in the forum ... )
So  ... hereafter the solutions i can imagine :
- if you want to stay in the trigger way, the user just have to click another object in mod3 to reset the sync event ...not always easy with big objects ;)
- you can add the drop script in the contextual menu of mod3 to 'allow' the drop ... the contextual menu is firing when you drop -> seems to be the best way to do it ! 
- you can add a GUI able to store all the source objects and then to do the drop part in a second time (just a list with 2 buttons ... no big deal)
- you can use an other app to simulate a click every xxx millisecond in order to reset the sync event (no ... this one is not real ;D)

 

Feel free to post your code if you are in trouble ;)

After thinking more about "requirements"... I realized that the utility should include creating links between the objects copy-dragged across modules (to show their ancestry).  This opened up an option for a new approach; that approach is to create a DXL attribute to capture links on the object and set trigger to fire on change of that attribute (i.e. after link creation).   So rather than dragging the objects, the use case is now do a "copy & link" step, which then allows me to do the needed post processing (after the object copy).  In any case, thanks so much for your help.   All of your suggestions were insightful and feasible.  Side note: your drag-and-drop example code taught me a lot about that functionality.  Thanks again!