Drag and drop lwjgl3

Started by MatthewNicholls, November 19, 2014, 14:12:19

Previous topic - Next topic

MatthewNicholls

I just started to look at lwjgl3 and found the 'drop' call back.
How can I get a String[] from the drop callback method?

public abstract void drop(long window,
        int count,
        long names)

the parameter for names is : 
Quotepointer to the array of UTF-8 encoded path names of the dropped files


spasi

See the GLFW events demo on github:

@Override
public void drop(long window, int count, long names) {
	printEvent(window, "drop %d file%s", count, count == 1 ? "" : "s");

	PointerBuffer nameBuffer = memPointerBuffer(names, count);
	for ( int i = 0; i < count; i++ ) {
		System.out.format("\t%d: %s%n", i + 1, memDecodeUTF8(memByteBufferNT1(nameBuffer.get(i))));
	}
}


A user-friendly utility method should probably be added for this.

MatthewNicholls

Thank you spasi. Works like a charm ;D.

XenoAmess

for new commers:
memDecodeUTF8 has already been renamed to memUTF8