Add an open-file popup dialog function

Issue #985 open
Eliter Scripts
created an issue

can there be something like,Arg2) can everyone who is looking at this go into Google Chrome (a web browser, look it up), type in "Chrome://settings" in the address bar, scroll down all the way to "Show advanced settings..." and click that. Then to the left of the "Download location:" there is a box, click it. See that window that popped up? can you guys put that into love2d, so like a User Avatar picture would be EASY for the user to locate. It would be so awesome. Now, for, the first Argument, being what directory to be looking first (Like, in chrome, it's probably at, by default, looking at "C:\USERNAME\Downloads"), the Second argument could be nil, OR a string. The second argument, if it is nil, then ALL the directories and files will be displayed. When the second argument is a string, it will look at ALL the directories, but will only view the file extension that is the same as the string that is Arg2.

That make sense?

Comments (21)

  1. Alex Szpakowski

    LÖVE 0.10.0 will have support for dropping files and folders onto the game's window. Will that be enough for you, or would an open-file-dialog function still be useful?

    (Also, for reference, is there a standardized API for this in Linux? On Windows there's GetOpenFileName and on OS X there's NSOpenPanel.)

  2. Eliter Scripts reporter

    Im not sure what "an openj-file-dialog function" is. Sorry. Also, is there a possibility that there could be ability to move in and out of windows. Like, after you download something on Chrome, you can drag the file from the bottom bar, onto your desktop, or drag a file from somewhere else, and drop it into a website. I think you could play around with some ideas from love.window.showMessageBox() stuff.

  3. Eliter Scripts reporter

    Yeah, I think an "open-file-dialog function" would be pretty cool. But, if drag-and-drop is all you can do, it would totally work. It's just that I'm creating a program, that requires a directory to be chosen, and files being read in it, but I need the user to decide every time it runs, where the directory is.

  4. Robert M.

    @Alex Szpakowski I think the addition of an "open-file dialog" would especially be handy for tools like level editors, paint applications and other utilities made with LÖVE.

    Then again "drag & drop" might be more convenient anyway ...

  5. Kyle McLamb

    For anybody who comes across this issue, I made a set of bindings to get Windows/MacOS/Linux file pickers, that I've been using just fine with love:

    Note: it's a blocking API, so I suggest spawning a thread to handle dialog boxes, and since the underlying library doesn't ask for a parent window it doesn't do the thing native dialogs do where they redirect focus from their parent to them, but it works okay4me

  6. Daniel Power

    If you're willing to include imgui, I've written a file picker dialog that should work for you. Screenshot_2017-07-26_14-40-52.png

    I wrote it for my animation editor called Motion. But I made sure when I wrote the file picker that it would be portable for use in future projects.

    You can find it here: The filedialog itself is in widgets/imguiFile.lua For an example of how to use it look at interface.lua since that's where all the calls are.

    Edit: A previous version had support for thumbnail previews, but it's been temporarily removed while I improve the layout.

  7. Daniel Power

    Once 0.11 is released, I'm going to begin packaging luafilesystem and imgui with the file dialog, and dropping them into the save directory, since (according to holo on irc) love will 0.11 will use the save directory as cpath.

    That way no dependencies will need to be installed manually.

  8. Pablo Mayobre

    I support @Kyle McLamb proposal of using nativefiledialogs, the dependency is really small and pretty much crossplatform (works in Windows, Linux and MacOSX)

    For me it just worked out of the box, it was really easy to build it too

  9. Mi 28

    Given that you cannot mount a point you didn't select in current session, its usability is limited, at best. To leverage the filesystem you'll have to bite into physfs via FFI, and at that point you might as well bring your own binary library for native dialogs.

  10. itraykov

    To be honest, I don't think this is a good idea. Even if you were to write an editor in Love2D, the native file dialog would look out of place with your editor. Would not be very convenient in full-screen mode either. So yea, it's probably best to use something like Daniel Power's solution.

  11. Ross Grams

    Yes, built-in nativefiledialogs support (or similar) would be really, really nice. You can't beat the native dialogs for UX. I would use it constantly for various editors, tools, and loading user-made content (custom maps, mods, images, etc.).

    I have to disagree with itraykov. Personally, on the occasions when I would actually care about looks (i.e. not for an editor) I think a native dialog would look much more professional than any homebrew solution.

    Dropping files and folders onto the window is nice, but for me it's not as good as an Open/Save As dialog, and definitely not the first method that comes to mind.

  12. Log in to comment