[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

api[www,Clipboard] code

DOMEvent
	subclass: #ClipboardEvent
	instanceVariableNames: ' '
	category: #Clipboard!
ClipboardEvent comment: '
	Provides clipboard operations such as copy, cut and paste in web applications.
	http://www.w3.org/TR/clipboard-apis/
	@2012 Alejandro Reimondo [email protected]
'!

"#clipboardData is aDataTransfer
See http://www.w3.org/TR/html5/editing.html#the-datatransfer-interface
"
ClipboardEvent buildGetters: #( #clipboardData )!

! ClipboardEvent class methodsFor: 'instance creation' !
type: aType with: initDictionary
	" Return an instance of the receiver. "

	| aHandle |
	aHandle := {' new ClipboardEvent(aType,initDictionary) '}.
	^self @ aHandle! !

! ClipboardEvent class methodsFor: 'instance creation' !
type: aType bubbles: bubbles cancelable: cancelable dataType: dataType data: data
	" Return an instance of the receiver. "

	| aHandle |
	aHandle := {' new ClipboardEvent(aType,{bubbles: bubbles, cancelable: cancelable, dataType: dataType, data: data}) '}.
	^self @ aHandle! !

! ClipboardEvent class methodsFor: 'instance creation' !
paste: data type: dataType
	" Return an instance of the receiver. "

	^self	type: #paste
		bubbles: true cancelable: true
		dataType: dataType data: data! !

! ClipboardEvent class methodsFor: 'instance creation' !
paste: data type: dataType
	" Return an instance of the receiver. "

	^self	type: #paste
		bubbles: true cancelable: true
		dataType: dataType data: data! !

! ClipboardEvent class methodsFor: #paste !
pasteString: aString
	" Paste aString onto Clipboard of document. "

	^(self paste: aString type: 'text/plain') dispatch! !

! ClipboardEvent methodsFor: #dispatch !
dispatch
	" Dispatch the receiver. "

	^DOM document dispatchEvent: self! !