wxRuby Documentation Home

Wx::DropSource

This class represents a source for a drag and drop operation.

See Drag and drop overview and DataObject overview for more information.

Derived from

None

Types

DragResultDragResult is defined as follows:

enum DragResult
{
    DragError,    // error prevented the d&d operation from completing
    DragNone,     // drag target didn't accept the data
    DragCopy,     // the data was successfully copied
    DragMove,     // the data was successfully moved (MSW only)
    DragLink,     // operation is a drag-link
    DragCancel    // the operation was cancelled by user (not an error)
};

See also

DropTarget, TextDropTarget, FileDropTarget

Methods

DropSource.new

DropSource.new(Window win = nil, 
              IconOrCursor iconCopy = NullIconOrCursor, 
               IconOrCursor iconMove = NullIconOrCursor, 
               IconOrCursor iconNone = NullIconOrCursor)
DropSource.new(DataObject data,  Window win = nil, 
              IconOrCursor iconCopy = NullIconOrCursor, 
               IconOrCursor iconMove = NullIconOrCursor, 
               IconOrCursor iconNone = NullIconOrCursor)

The constructors for DataObject.

If you use the constructor without data parameter you must call set_data later.

Note that the exact type of iconCopy and subsequent parameters differs between MSW and GTK: these are cursors under Windows but icons for GTK. You should use the macro DROP_ICON in portable programs instead of directly using either of these types.

Parameters

win is the window which initiates the drag and drop operation.

destructor()

DropSource#set_data

set_data(DataObject data)

Sets the data DataObject associated with the drop source. This will not delete any previously associated data.

DropSource#do_drag_drop

DragResult do_drag_drop(Integer flags = Drag_CopyOnly)

Do it (call this in response to a mouse button press, for example). This starts the drag-and-drop operation which will terminate when the user releases the mouse.

Parameters

Return value

Returns the operation requested by the user, may be DragCopy, DragMove, DragLink, DragCancel or DragNone if an error occurred.

DropSource#get_data_object

DataObject get_data_object()

Returns the DataObject object that has been assigned previously.

DropSource#give_feedback

Boolean give_feedback(DragResult effect)

Overridable: you may give some custom UI feedback during the drag and drop operation in this function. It is called on each mouse move, so your implementation must not be too slow.

Parameters

Return value

Return false if you want default feedback, or true if you implement your own feedback. The return values is ignored under GTK.

DropSource#set_cursor

set_cursor(DragResult res,  Cursor cursor)

Set the icon to use for a certain drag result.

Parameters

[This page automatically generated from the Textile source at Wed Sep 09 02:21:06 +0100 2009]