Skip to content
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

Can't see how to use declaration style #2

Closed
owencm opened this issue Mar 9, 2018 · 1 comment
Closed

Can't see how to use declaration style #2

owencm opened this issue Mar 9, 2018 · 1 comment

Comments

@owencm
Copy link

owencm commented Mar 9, 2018

Hi, thanks for your work on this project!

I'm trying to work with CoreGraphics and can't see how to do that with objc

For example, I'm trying to call CGEventCreate(null) by writing:

const objc = require('objc')
objc.import('Cocoa')
objc.import('Framework')
const {CGEventCreate} = objc
const test = CGEventCreate(null)

but I'm getting back an error that CGEventCreate is not a function, and that it's value is 'H��AW'.

Any pointers for how to get this to work?

@lukaskollmer
Copy link
Owner

lukaskollmer commented Mar 9, 2018

The problem is that CoreGraphics is entirely written in C, meaning that you'll have to access it via the ffi module:

const ffi = require('ffi');
const objc = require('objc');
objc.import('CoreGraphics');

const lib = new ffi.Library(null, {
  CGEventCreate: ['pointer', ['pointer']]
});

const event = lib.CGEventCreate(null);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants