File Dialog

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

File Dialog

ebouchare
Hi All,

First of all, thanks for this lua package on palm.

I have just uploaded the file 'FileDialog.lua' to the sources section
in the file directory.

It implements a simple File Browser for the vfs0: device.

function FileDialog(path)
  ...
  return result,path,file
end
path=nil
local b = gui.control{type="button", text='file dialog', x=100, y=50}
gui.nl()



while true do
  local e,id,a1 = gui.event()

  if e==ctlSelect then
    if id==b then
      local res,path,file=FileDialog(path)
      if res==true then
        print(path..file)
      end
    end
  elseif e == appStop then
    break
  end
end

The function FileDialog returns a boolean to tell if the OK button was
pushed (true), the path selected and a filename.

One can set a path where to begin browsing from (it must be a valid
path) or nil to begin from the root vfs0:/

One can, as well, make new directories.

I hope it will be of any interest to some people on the list. This has
been developped on a Tungsten E2 (320x320 screen). There may be some
changes to do it work with 160x160 screen (?).

Eric