Hello Guest

Drag and drop lwjgl3

  • 3 Replies
  • 5765 Views
Drag and drop lwjgl3
« 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?
 
Code: [Select]
public abstract void drop(long window,
        int count,
        long names)
the parameter for names is : 
Quote
pointer to the array of UTF-8 encoded path names of the dropped files


*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Drag and drop lwjgl3
« Reply #1 on: November 19, 2014, 15:27:14 »
See the GLFW events demo on github:

Code: [Select]
@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.

Re: Drag and drop lwjgl3
« Reply #2 on: November 19, 2014, 15:58:54 »
Thank you spasi. Works like a charm ;D.

Re: Drag and drop lwjgl3
« Reply #3 on: June 20, 2019, 09:54:17 »
for new commers:
memDecodeUTF8 has already been renamed to memUTF8