EZ
Up Prev Next Contents


7 Drag and Drop

EZwgl supports drag and drop. Most widgets and display items are potentially drag sources and/or drop targets. An object becomes a drag source if it has one or more DnD encoders registered to it. An object becomes a drop target if it has one or more DnD decoders registered.

DnD encoders and DnD decoders are procedures of the following prototypes.

int encoder(void *object, void *data, char **message, int *length, int *needFree) int decoder(void *object, void *data, char *message, int length)

When invoked by EZwgl, object is the widget or display item the procedure is registered to. data is the client data the application has told EZwgl to pass back when invoked. For encoders, message returns the encoded message, length returns the length of message and needFree returns a boolean value signals whether EZwgl should free the encoded message when done with it. For decoders, message and length are the message and the length of the message passed by EZwgl. The message will be automatically freed by EZwgl when the relevent DnD transaction finishes. Both encoders and decoders should return EZ_DND_SUCCESS if conversion succeed and return EZ_DND_FAILUER when conversion fails.

You can only transfer data in 8-bit quantities using DnD. If you need to transfer information of other kinds, for example, 4 bytes quantities, you'll have to engineer your encoder and decoder to convert the quantity to and from 8-bit quantities.


Up Prev Next Contents

HTML Documentation Maintainance:Arturo Espinosa <arturo@nuclecu.unam.mx>