Hi,
I'm trying to use the dropCallback of GLFW
GLFW.glfwSetDropCallback(window, dropCallBack = new GLFWDropCallback()
{
@Override
public void invoke(long window, int count, long names)
{
}
});
In the documentation I only find that "names" is a pointer to the array of UTF-8 encoded path names of the dropped files.
But I dont have any glue how to get a readable string from the long.
I dont find anything about this function in the forum.
Would be great if someone could help me.
Thanks a lot and best regards
Lobo
This will do:
public void invoke(long window, int count, long names) {
PointerBuffer charPointers = MemoryUtil.memPointerBuffer(names, count);
for (int i = 0; i < count; i++) {
String name = MemoryUtil.memUTF8(charPointers.get(i));
System.err.println(name); // <- test: print out the path
}
// We MUST NOT call MemoryUtil.memFree(charPointers), because
// the memory is managed by GLFW internally.
}
Perfect. Thanks a lot!
There's also a shortcut available:
glfwSetDropCallback(window, (windowHnd, count, names) -> {
for ( int i = 0; i < count; i++ ) {
String name = GLFWDropCallback.getName(names, i);
System.err.println(name);
}
});