pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Rescue Screenshot

Open Ducasse opened this issue 2 months ago • 0 comments

makeAScreenshot is now in morphic but we could have it at the level of Spec.

makeAScreenshot

	| filePrefix |
	filePrefix := 'PharoScreenshot'.
	(MorphicUIManager new
		 chooseFrom: {
				 'The entire world' translated.
				 'A selected area' translated }
		 values: #( #world #area )
		 message:
			 'What do you want to shoot? (File will be saved in image directory)'
				 translated
		 title: 'Make a screenshot') ifNotNil: [ :choice |
		| form name |
		form := choice = #world
			        ifTrue: [ self currentWorld imageForm ]
			        ifFalse: [ Screenshot new formScreenshotFromUserSelection ].
		name := (FileSystem workingDirectory / filePrefix , 'png')
			        nextVersion.
		PNGReadWriter
			putForm: form
			onFileNamed:
			(FileSystem workingDirectory / filePrefix , 'png') nextVersion.
		MorphicUIManager new
			inform: (String streamContents: [ :s |
					 s
						 nextPutAll: 'Screenshot saved under ';
						 nextPutAll: name fullName;
						 cr;
						 nextPutAll: 'Click to open location' ])
			actionOnClick: [ name openInOSFileBrowser ] ]

Ducasse avatar Dec 06 '25 14:12 Ducasse