Class: Browser::Event::DataTransfer
- Includes:
- NativeCachedWrapper
- Defined in:
- opal/browser/event/data_transfer.rb
Overview
DataTransfer is an object which manages included data to an event of type Drag or Clipboard.
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#drag_image ⇒ Object
writeonly
Sets a drag image for this DataTransfer.
-
#effect ⇒ Symbol
Effect of this drop operation.
-
#files ⇒ Array<File>
readonly
List of files attached to this DataTransfer.
-
#items ⇒ Array<Item>
readonly
List of items attached to this DataTransfer.
Instance Method Summary collapse
-
#[](type) ⇒ Object
Extract some text data from this DataTransfer instance.
-
#[]=(type, value) ⇒ Object
Embed some text data in this DataTransfer instance.
-
#clear(type = nil) ⇒ Object
Clear some (or all, if type is not specified) text data from this DataTransfer instance.
Methods included from NativeCachedWrapper
#restricted?, #set_native_reference
Instance Attribute Details
#drag_image=(value) ⇒ Object (writeonly)
Sets a drag image for this Browser::Event::DataTransfer. Use some DOM::Element::Image or Canvas as a value.
40 41 42 |
# File 'opal/browser/event/data_transfer.rb', line 40 def drag_image= (image) `#@native.setDragImage(#{Native.convert(image)})` end |
#effect ⇒ Symbol
Returns Effect of this drop operation. Must be one of: :none, :copy, :link or :move.
13 14 15 |
# File 'opal/browser/event/data_transfer.rb', line 13 def effect `#@native.dropEffect` end |
#files ⇒ Array<File> (readonly)
Returns list of files attached to this Browser::Event::DataTransfer.
46 47 48 |
# File 'opal/browser/event/data_transfer.rb', line 46 def files Native::Array.new(`#@native.files`).map { |f| File.new(f.to_n) } end |
#items ⇒ Array<Item> (readonly)
Returns list of items attached to this Browser::Event::DataTransfer.
52 53 54 |
# File 'opal/browser/event/data_transfer.rb', line 52 def items Native::Array.new(`#@native.items`).map { |i| Item.new(i.to_n) } end |
Instance Method Details
#[](type) ⇒ Object
Extract some text data from this Browser::Event::DataTransfer instance.
22 23 24 |
# File 'opal/browser/event/data_transfer.rb', line 22 def [] (type) `#@native.getData(#{type})` end |
#[]=(type, value) ⇒ Object
Embed some text data in this Browser::Event::DataTransfer instance.
27 28 29 |
# File 'opal/browser/event/data_transfer.rb', line 27 def []= (type, value) `#@native.setData(#{type}, #{Native.convert(value)})` end |
#clear(type = nil) ⇒ Object
Clear some (or all, if type is not specified) text data from this Browser::Event::DataTransfer instance.
33 34 35 |
# File 'opal/browser/event/data_transfer.rb', line 33 def clear (type=nil) `#@native.clearData(#{type.to_n})` end |