LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: MatthewNicholls on November 19, 2014, 14:12:19

Title: Drag and drop lwjgl3
Post by: MatthewNicholls on November 19, 2014, 14:12:19
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

Title: Re: Drag and drop lwjgl3
Post by: spasi on November 19, 2014, 15:27:14
See the GLFW events demo (https://github.com/LWJGL/lwjgl3/blob/master/src/tests/org/lwjgl/demo/glfw/Events.java) 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.
Title: Re: Drag and drop lwjgl3
Post by: MatthewNicholls on November 19, 2014, 15:58:54
Thank you spasi. Works like a charm ;D.
Title: Re: Drag and drop lwjgl3
Post by: XenoAmess on June 20, 2019, 09:54:17
for new commers:
memDecodeUTF8 has already been renamed to memUTF8