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.
42 43 44 |
# File 'opal/browser/event/data_transfer.rb', line 42 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.
15 16 17 |
# File 'opal/browser/event/data_transfer.rb', line 15 def effect `#@native.dropEffect` end |
#files ⇒ Array<File> (readonly)
Returns list of files attached to this Browser::Event::DataTransfer.
48 49 50 |
# File 'opal/browser/event/data_transfer.rb', line 48 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.
54 55 56 |
# File 'opal/browser/event/data_transfer.rb', line 54 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.
24 25 26 |
# File 'opal/browser/event/data_transfer.rb', line 24 def [] (type) `#@native.getData(#{type})` end |
#[]=(type, value) ⇒ Object
Embed some text data in this Browser::Event::DataTransfer instance.
29 30 31 |
# File 'opal/browser/event/data_transfer.rb', line 29 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.
35 36 37 |
# File 'opal/browser/event/data_transfer.rb', line 35 def clear (type=nil) `#@native.clearData(#{type.to_n})` end |