PDA

View Full Version : getting my head around drag and drop



jboyd4650
October 7th, 2013, 17:56
i think i need a more specific demo of drag and drop. what i am looking for is a simple drag a race name and drop in in the race 'box' for a character sheet. what i really need is: how, and where to grab a string. then drop it on the chosen location. (i really need a basic where the code is placed, and what is needed to receive the date.


any help or point to threads i may have missed would be appreciated.

James

Moon Wizard
October 7th, 2013, 23:14
When a user clicks on a windowcontrol object and begins dragging, an onDragStart event is fired for the windowcontrol. One of the parameters passed into the event function is a dragdata object. If your windowcontrol script is handling the event, then it would update the dragdata object with the drag "type", strings, numbers, shortcuts, dice, etc.; then, return true to tell FG that the script is handling the drag event and not to perform the default processing for the control (i.e. drag text if stringcontrol, drag number if numbercontrol, etc.).

When the user releases a dragdata object onto another windowcontrol, that windowcontrol receives an onDrop event with the dragdata object passed as a parameter. Then, the windowcontrol can inspect the dragdata object to determine whether it is a drag type that it wants to capture, inspect any elements, and return true or false to tell FG whether it is handling the drop event.

There are several examples of drag and drop handling in the built-in rulesets (3.5E / 4E). Just look for "function onDragStart" and "function onDrop".

Regards,
JPG