-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for NSPasteboard #25
Conversation
I love the links to relevant docs, I really wanted to do that. Hopefully others will continue or we can just make it part of the PR acceptance process. Some other places I look for constant values, if the docs don't say, sometimes you can find out from |
I want to read pictures from pasteboard. gp := cocoa.NSPasteboard_GeneralPasteboard()
s := gp.Send("dataForType:", core.NSString_FromString(cocoa.NSPasteboardTypePNG)).String() I can read file info, but I don’t know how to save file. I try to write like this, but I still can't save it as a picture correctly. Do you have any good ideas? |
I will take a look |
I got it working:
|
I will need to go now might open PR later with an example or some nicer api for length and bytes |
I tried. It works. Excellent! |
Maybe like this func (pb NSPasteboard) DataForType(t NSPasteboardType) []byte {
data := pb.Send("dataForType:", core.NSString_FromString(t))
objcBytes := data.Get("bytes")
length := data.Get("length")
return C.GoBytes(unsafe.Pointer(objcBytes.Pointer()), C.int(length.Uint()))
} |
#31 is open and adds a bunch of utility to improve the workflow when using NSPasteboard |
This PR adds support for NSPasteboard. Currently it covers the basic read from and write to pasteboard operations.
I included the objc code that i used to get the constants as comment. If anyone knows how we can access them directly instead let me know. I would gladly replace it.
Also i did not include the constants
NSFileContentsPboardType
,NSFindPanelSearchOptionsPboardType
Pasteboard types as they had different contents that i was not sure about.In terms of testing, i use this as showcased in the example with string only for now and have not yet tested pictures or anything else.
Also i spend some time to get the original apple doc comments converted and linked in the relevant places. Not sure if we want to do this or not.