objc icon indicating copy to clipboard operation
objc copied to clipboard

how convert nativeWindowHandle to NSView

Open xingyibiao opened this issue 5 years ago • 8 comments

I want to convert nativeWindowHandle to NSView, like

const myView = win.getNativeWindowHandle()
$.myFramework.setView(myView)

any suggestion?

xingyibiao avatar Apr 23 '19 02:04 xingyibiao

where are you getting the native window handle from?

lukaskollmer avatar May 04 '19 09:05 lukaskollmer

I use electron

xingyibiao avatar May 05 '19 06:05 xingyibiao

have you tried objc.wrap?

const viewObject = objc.wrap(win.getNativeWindowHandle());

lukaskollmer avatar May 05 '19 07:05 lukaskollmer

I have tried, but objc can not receive NSView, It will be Buffer? not NSView?

xingyibiao avatar May 09 '19 14:05 xingyibiao

I know this is two years later, but any updates on this? It would be nice if I could use this library with electron to do some simple operations on NSWindow. If i try to run let nativeWindow = objc.wrap(screenshotWindow.getNativeWindowHandle()) objc spits out the ambiguous error: Attempt to use unknown class 0x7fd84748ea30.

ImpossibleReality avatar Nov 14 '21 20:11 ImpossibleReality

Came here because I was also trying to figure this out and Google lead me here. I did end up figuring it out: you need to call .readPointer() on the buffer returned from getNativeWindowHandle(), e.g.

const handle = mainWindow.getNativeWindowHandle().readPointer()
const nsview = objc.wrap(handle)
nsview.window().invalidateShadow()

nornagon avatar Jan 13 '22 19:01 nornagon

wrap

Have you resolve this problem? thanks

Lijian1122 avatar Feb 07 '22 03:02 Lijian1122

Have you resolve this problem? thanks

readPointer

when I run the programe, it show error: readPointer is not a function

Lijian1122 avatar Feb 07 '22 03:02 Lijian1122