Class: Wx::DropTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/drag_drop.rb

Overview

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

A DataObject can be associated with it and by default, this object will be filled with the data from the drag source, if the data formats supported by the data object match the drag source data format. There are various virtual handler functions defined in this class which may be overridden to give visual feedback or react in a more fine-tuned way, e.g. by not accepting data on the whole window area, but only a small portion of it. The normal sequence of calls is #on_enter, #on_drag_over possibly many times, #on_drop and finally #on_data.

Category: Clipboard and Drag & Drop

See Also:

Requires:

  • USE_DRAG_AND_DROP

Direct Known Subclasses

FileDropTarget, TextDropTarget

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Wx::DropTarget

Constructor.

data is the data to be associated with the drop target.

Parameters:



196
# File 'lib/wx/doc/gen/drag_drop.rb', line 196

def initialize(data=nil) end

Instance Method Details

#get_dataBoolean Also known as: data

This method may only be called from within #on_data.

By default, this method copies the data from the drop source to the Wx::DataObject associated with this drop target, calling its Wx::DataObject#set_data method.

Returns:

  • (Boolean)


202
# File 'lib/wx/doc/gen/drag_drop.rb', line 202

def get_data; end

#get_data_objectWx::DataObject Also known as: data_object

Returns the data Wx::DataObject associated with the drop target.

Returns:



252
# File 'lib/wx/doc/gen/drag_drop.rb', line 252

def get_data_object; end

#get_default_actionWx::DragResult Also known as: default_action

Returns default action for drag and drop or Wx::DragResult::DragNone if this not specified.

Returns:



271
# File 'lib/wx/doc/gen/drag_drop.rb', line 271

def get_default_action; end

#on_data(x, y, defResult) ⇒ Wx::DragResult

Called after #on_drop returns true.

By default this will usually #get_data and will return the suggested default value defResult.

Parameters:

Returns:



212
# File 'lib/wx/doc/gen/drag_drop.rb', line 212

def on_data(x, y, defResult) end

#on_drag_over(x, y, defResult) ⇒ Wx::DragResult

Called when the mouse is being dragged over the drop target.

By default, this calls functions return the suggested return value defResult.

The desired operation or Wx::DragResult::DragNone. This is used for optical feedback from the side of the drop source, typically in form of changing the icon.

Parameters:

  • x (Integer)

    The x coordinate of the mouse.

  • y (Integer)

    The y coordinate of the mouse.

  • defResult (Wx::DragResult)

    Suggested value for return value. Determined by SHIFT or CONTROL key states.

Returns:



223
# File 'lib/wx/doc/gen/drag_drop.rb', line 223

def on_drag_over(x, y, defResult) end

#on_drop(x, y) ⇒ Boolean

Called when the user drops a data object on the target.

Return false to veto the operation.

true to accept the data, or false to veto the operation.

Parameters:

  • x (Integer)

    The x coordinate of the mouse.

  • y (Integer)

    The y coordinate of the mouse.

Returns:

  • (Boolean)


233
# File 'lib/wx/doc/gen/drag_drop.rb', line 233

def on_drop(x, y) end

#on_enter(x, y, defResult) ⇒ Wx::DragResult

Called when the mouse enters the drop target.

By default, this calls #on_drag_over.

The desired operation or Wx::DragResult::DragNone. This is used for optical feedback from the side of the drop source, typically in form of changing the icon.

Parameters:

  • x (Integer)

    The x coordinate of the mouse.

  • y (Integer)

    The y coordinate of the mouse.

  • defResult (Wx::DragResult)

    Suggested default for return value. Determined by SHIFT or CONTROL key states.

Returns:



244
# File 'lib/wx/doc/gen/drag_drop.rb', line 244

def on_enter(x, y, defResult) end

#on_leavevoid

This method returns an undefined value.

Called when the mouse leaves the drop target.



248
# File 'lib/wx/doc/gen/drag_drop.rb', line 248

def on_leave; end

#set_data_object(data) ⇒ void Also known as: data_object=

This method returns an undefined value.

Sets the data Wx::DataObject associated with the drop target and deletes any previously associated data object.

Parameters:



258
# File 'lib/wx/doc/gen/drag_drop.rb', line 258

def set_data_object(data) end

#set_default_action(action) ⇒ void Also known as: default_action=

This method returns an undefined value.

Sets the default action for drag and drop.

Use Wx::DragResult::DragMove or Wx::DragResult::DragCopy to set default action to move or copy and use Wx::DragResult::DragNone (default) to set default action specified by initialization of dragging (see Wx::DropSource#do_drag_drop)

Parameters:



266
# File 'lib/wx/doc/gen/drag_drop.rb', line 266

def set_default_action(action) end