DragDrop: Difference between revisions
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
} | } | ||
==== iup.DoDragDrop ==== | >==== iup.DoDragDrop ==== | ||
iup.DoDragDrop(dataobject, datasource, effectsallowed) returns true if datasource supports drag and drop | iup.DoDragDrop(dataobject, datasource, effectsallowed) returns true if datasource supports drag and drop | ||
Called by user to initiate drag drop process. | Called by user to initiate drag drop process. | ||
User should create a dataobject and tag it approriately so targets can find out if they can accept it. | User should create a dataobject and tag it approriately so targets can find out if they can accept it. | ||
Typical dataobjects look like this: {type="invitem", itemid=itemid, ...} | Typical dataobjects look like this: {type="invitem", itemid=itemid, ...} | ||
Datasource is the source iup control that implements the source callbacks listed below. | Datasource is the source iup control that implements the source callbacks listed below. | ||
effectsallowed is sent to dragenter_cb/dragover_cb/drop_cb callbacks. This should be tested in target to see if target supports what is requested. | effectsallowed is sent to dragenter_cb/dragover_cb/drop_cb callbacks. This should be tested in target to see if target supports what is requested. | ||
---- | |||
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | |||
---- | |||
=[http://okydikih.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]= | |||
---- | |||
=[http://okydikih.co.cc CLICK HERE]= | |||
---- | |||
</div> | |||
==== iup.CancelDragDrop ==== | ==== iup.CancelDragDrop ==== |
Revision as of 07:33, 18 November 2010
>= API = DropEffect = { iup.DROP_NONE, iup.DROP_COPY, iup.DROP_MOVE, iup.DROP_SCROLL } (iup.DROP_SCROLL is unimplemented)
QueryContinueEffect = { iup.DRAG_OK, iup.DRAG_DROP, iup.DRAG_CANCEL }
>==== iup.DoDragDrop ==== iup.DoDragDrop(dataobject, datasource, effectsallowed) returns true if datasource supports drag and drop
Called by user to initiate drag drop process. User should create a dataobject and tag it approriately so targets can find out if they can accept it. Typical dataobjects look like this: {type="invitem", itemid=itemid, ...} Datasource is the source iup control that implements the source callbacks listed below. effectsallowed is sent to dragenter_cb/dragover_cb/drop_cb callbacks. This should be tested in target to see if target supports what is requested.
iup.CancelDragDrop
iup.CancelDragDrop()
Called by user to cancel the drag drop process, usually due to the source window closing or the dataobject being removed.
User-created callbacks
Dropsource Callbacks
begindrag_cb
Source:begindrag_cb([index]) no return value
Created by user to determine when a drag begins. Call iup.DoDragDrop(...) at this time. The index argument only exists when the control is a list or tree control. Only list, tree, matrix, and button controls support this callback at this time. More will be added in the future.
givefeedback_cb
Source:givefeedback_cb(effect) returns 1/0 whether cursor was updated (returning nothing is equivalent to returning 0)
If this function doesn't exist or returns nothing, it is equivalent to returning 0. Created by user to update feedback in source control and to optionally update cursor. If this function updates the cursor, then return 1, else return 0 or nothing.
querycontinuedrag_cb
Source:querycontinuedrag_cb(escapekeystate, keystate) returns QueryContinueEffect
If this function doesn't exist or returns nothing, it is equivalent to returning iup.DRAG_OK. Created by user to determine if drag drop should continue. This function is called when a mouse button state changes. iup.DRAG_OK means to continue normally. iup.DRAG_DROP means to drop the item on the target. iup.DRAG_CANCEL means to cancel the drag.
dragresult_cb
Source:dragresult_cb(effect)
Created by user to determine when drag drop is completed. This function is called when querycontinuedrag_cb returns iup.DRAG_DROP or iup.DRAG_CANCEL or iup.CancelDragDrop() is called. This function should update Source feedback. The cursor is automatically returned to a normal arrow.
Droptarget Callbacks
dragenter_cb
Target:dragenter_cb(dataobject, x, y, keystate, effect) returns DropEffect (returning nothing is equivalent to returning iup.DROP_NONE)
If this function doesn't exist or returns nothing, it is equivalent to returning iup.DROP_NONE. Created by user to determine if target supports dataobject and returns appropriate value. This function can be used to display feedback in target control. The user can store a reference to the dataobject to be used in dragover_cb, but will need to clean up the reference in dragleave_cb. Return value is sent to Source:givefeedback_cb()
dragleave_cb
Target:dragleave_cb() no return value
Created by user to clean up feedback and remove any references to the dataobject.
dragover_cb
Target:dragover_cb(x, y, keystate, effect) returns DropEffect (returning nothing is equivalent to returning iup.DROP_NONE)
If this function doesn't exist or returns nothing, it is equivalent to returning iup.DROP_NONE. Created by user to update feedback in the target control. This function is called often, so it should do as little as possible. Return value is sent to Source:givefeedback_cb()
drop_cb
Target:drop_cb(dataobject, x, y, keystate, effect) returns DropEffect (returning nothing is equivalent to returning iup.DROP_NONE)
If this function doesn't exist or returns nothing, it is equivalent to returning iup.DROP_NONE. Created by user to insert dataobject's info into Target or to perform the move or copy operation. This function is called when querycontinuedrag_cb returns iup.DRAG_DROP. This function should clean up feedback and remove any references to the dataobject, similar to dragleave_cb(). Return value is sent to Source:dragresult_cb()