One of the things I've been having trouble with, is the dragging of an item from a players inventory to the store window to sell the item. Well with the hope of people in #nwn2cr I've finally got this working. I though I'd post about it as this kind of information is very hard to find.
My main mistake was trying to retrieve the event of a item been dropped on store GUI. This is actually done from the inventory screen.
Their are two events that were confusing me. OnMouseDrop and OnMouseDropReceived. So in a drag operation between two dialogs (in my case the inventory and the store) their is a source and destination of the drag operation. The source will fire the event OnMouseDrop, and the destination will fire OnMouseDropReceived.
I've not been able to figure out how to capture the dragged object details using OnMouseDropReceived, but OnMouseDrop works very well. I used the two following calls to capture the objects ID and send to to the store sell script:
Their is another bit of magic that was also need. The above will fire for any event, so you need to know that the item is been dragged to the store. I added the following calls to the store window:
The script gui_store_mouse sets a variable on the player when the mouse pointer enters the store window and deletes it when the mouse pointer leaves. Now the gui_store_sell script can check the variable before selling the item.
I was hoping to use a combination of OnMouseDrop on the inventory dialog and OnMouseDropReceived on the store dialog, but it seems that OnMouseDropReceived is fired before OnMouseDrop.
Hope this helps another scripter/modder :-)