DonationCoder.com Software > Screenshot Captor
Bug: Cannot copy _both_ file path and image
eekboom:
I configured in the options to have Screenshot Captor copy both the file path and the image itself to the clipboard.
(Should be possible from my understanding of the windows clipboard, right?)
[attach=#2][/attach]
However it only ever copies the file path in that case:
[attach=#1][/attach]
ralfs:
I think these options can't be performed at the same time because windows clipboard only can hold one item (picture or text).
eekboom:
I think these options can't be performed at the same time because windows clipboard only can hold one item (picture or text).
-ralfs (December 08, 2011, 10:31 AM)
--- End quote ---
That's just wrong. (Even for text there are already four different formats in the clipboard, see the screenshot of the clipboard viewer in my previous post).
I just verified that the clipboard can also hold image and text formats at the same time: I wrote a small Java program that does exactly that.
When I run the code,
then paste into Paint.NET I get an image:
[attach=#1][/attach]
Paste into Word gets the text:
[attach=#2][/attach]
BTW my use case is: I am frequently using two issue trackers: YouTrack which has an option "Attach Image from Clipboard" and Jira where I need to upload a file. It would be nice to have the screenshot in both formats automatically, so that I can immediately use it on either bug tracker.
Main:
--- ---package de.eekboom.cliptest;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.image.BufferedImage;
public class Main {
public static void main(String[] args) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
BufferedImage bufferedImage = createImage();
TextAndImageContent content = new TextAndImageContent("Text & Image in Clipboard", bufferedImage);
clipboard.setContents(content, null);
}
private static BufferedImage createImage() {
BufferedImage bufferedImage = new BufferedImage(80, 40, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = bufferedImage.createGraphics();
graphics.setPaint(Color.RED);
graphics.fillOval(5, 5, 70, 30);
return bufferedImage;
}
}
Helper class:
--- ---package de.eekboom.cliptest;
import java.awt.datatransfer.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
public class TextAndImageContent implements Transferable, ClipboardOwner {
private final String text;
private final BufferedImage image;
private static final DataFlavor[] flavors = {
DataFlavor.stringFlavor,
DataFlavor.imageFlavor
};
public TextAndImageContent(String text, BufferedImage image) {
this.text = text;
this.image = image;
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return (DataFlavor[])flavors.clone();
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
for (DataFlavor supportedFlavor : flavors) {
if (flavor.equals(supportedFlavor)) {
return true;
}
}
return false;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(DataFlavor.stringFlavor)) {
return text;
}
if (flavor.equals(DataFlavor.imageFlavor)) {
return image;
}
return null;
}
@Override
public void lostOwnership(Clipboard clipboard, Transferable contents) {
}
}
Ath:
and Jira where I need to upload a file
-eekboom (December 08, 2011, 11:06 AM)
--- End quote ---
Even rather old Jira versions (4.0) have a nice page where you can paste an image (jpg/png) from the clipboard to be attached to the issue.
eekboom:
Right, thanks, I only just now noticed. In my defense: I think our client only updated to that Jira version recently.
Still the issue remains.
At the very least it is a usability bug: If there are two _checkboxes_ which I can both check, then it should work (and it is easy to implement as I demonstrated).
Otherwise there should be a radio group with two mutually exclusive radio buttons.
Navigation
[0] Message Index
[#] Next page
Go to full version