Class: Browser::Event::DataTransfer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#effectSymbol

Returns Effect of this drop operation. Must be one of: :none, :copy, :link or :move.

Returns:

  • (Symbol)

    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

#filesArray<File> (readonly)

Returns list of files attached to this Browser::Event::DataTransfer.

Returns:


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

#itemsArray<Item> (readonly)

Returns list of items attached to this Browser::Event::DataTransfer.

Returns:


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