[Cuis-dev] How do I read a file dragged and dropped on to the desktop?

H. Hirzel hannes.hirzel at gmail.com
Fri May 9 10:35:47 PDT 2025


The answer of an example implementation is below.

Now on

https://github.com/DrCuis/Technical/wiki/How_do_I_read_a_file_dragged_and_dropped_on_to_the_desktop

to be developed into a HowTo document.

--Hannes

--------------------------------------------------------------------------------------------------------------------------------------------------------

An example class |ReadDroppedFile| which implements a method 
|readDocBookFromFileEntry: aFileEntry| which is called when a file with 
a name ending with |book.xml| is dropped onto the desktop.

|'From Cuis7.3 [latest update: #7102] on 9 May 2025 at 7:21:59 pm'! 
!classDefinition: #ReadDroppedFile category: #MyFileDragAndDropExample! 
Object subclass: #ReadDroppedFile instanceVariableNames: '' 
classVariableNames: '' poolDictionaries: '' category: 
'MyFileDragAndDropExample'! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- 
-- -- -- -- "! !classDefinition: 'ReadDroppedFile class' category: 
#MyFileDragAndDropExample! ReadDroppedFile class instanceVariableNames: 
''! !ReadDroppedFile class methodsFor: 'as yet unclassified' stamp: 'hjh 
5/9/2025 19:07:40'! fileReaderServicesForFileEntry: aFileName suffix: 
aSuffix (aFileName name endsWith: 'book.xml') ifTrue: [ ^ { self 
serviceReadDocBookFile } ]. ^#()! ! !ReadDroppedFile class methodsFor: 
'as yet unclassified' stamp: 'hjh 5/9/2025 19:20:23'! 
readDocBookFromFileEntry: aFileEntry Transcript show: aFileEntry name; 
cr! ! !ReadDroppedFile class methodsFor: 'as yet unclassified' stamp: 
'hjh 5/9/2025 19:19:15'! serviceReadDocBookFile ^ (SimpleServiceEntry 
provider: self label: 'import as DocBook file' selector: 
#readDocBookFromFileEntry: description: 'import image as DocBook' 
buttonLabel: 'import DocBook' icon: #imageIcon ) argumentGetter: [ 
:fileList | fileList selectedFileEntry ]! ! |

||
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250509/781c4e7a/attachment.htm>


More information about the Cuis-dev mailing list