ExplorerList Help File

ExplorerList Help File

Plugin Name:

ExplorerList

Current Version:

1.0.0.2

Description:

Creates a listing of a directory just as Explorer does. It lets the user choose a file or a folder and (if you do not prevent it by a flag) navigate through the whole directory tree.

Licence:

Freeware

Author:

RizlaUK

Web:

www.luadevils.com

E-mail:

rizlauk@luadevils.com


Table of Contents

ExplorerList.Create
ExplorerList.GetPath
ExplorerList.SetPath
ExplorerList.GetSelectedItem
ExplorerList.GetSelectedItemType
ExplorerList.SetPattern
ExplorerList.SetDisplay
ExplorerList.SetCallback
ExplorerList.SetDropFiles
ExplorerList.GetSelectedItemTable

ExplorerList.Create


(boolean) ExplorerList.Create ( 

(string) Object,

(string) Path = "",

(string) Pattern = "*.*",

(table) Flags = nil )

Description

Creates a ExplorerList object.

Parameters

Object

(string) The name of the host object.

Note: The host object MUST be an AMS ListBox.

Path

(string) The initial displayed directory.

Note: The path must end with a lua backslash '\\'. Including no path will display the root containing the drives.

Pattern

(string) Include one or multiple patterns, like "*.lua;*.txt".

Note: Including no pattern defaults to '*.*'.

Flags

(table) Flags can be a combination of the following values:

CONSTANT

VALUE

DESCRIPTION

BorderLess

Boolean

Create object without borders.

AlwaysShowSelection

Boolean

The selection is visible, even when the object is not activated.

MultiSelect

Boolean

Enable multiple selection of items in the object.

GridLines

Boolean

Display separator lines between rows And columns.

HeaderDragDrop

Boolean

In report view, the headers can be changed by Drag'n'Drop.

FullRowSelect

Boolean

The selection covers the full row instead of the first column.

NoFiles

Boolean

No files will be displayed.

NoFolders

Boolean

No folders will be displayed.

NoParentFolder

Boolean

There will be no [..] link To the parent folder.

NoDirectoryChange

Boolean

The directory cannot be changed by the user.

NoDriveRequester

Boolean

There will be no 'please insert disk into drive X' displayed.

NoSort

Boolean

The user cannot sort the content by clicking on a column header.

NoMyDocuments

Boolean

The 'My Documents' Folder will Not be displayed.

AutoSort

Boolean

The content will be sorted automatically by name.

Returns

(boolean) True if the object was created, flase if any error.


Example

-- creates a ExplorerList in the object "ListBox1"
bCreate = ExplorerList.Create("ListBox1", nil, nil, tListFlags);
if bCreate then
    -- enables the user to drop files on object "ListBox1"
    ExplorerList.SetDropFiles("ListBox1", true);
    ExplorerList.SetCallback("ListBox1", "MyCallback");
else
    -- object could not be created
    -- Test for error
    error = Application.GetLastError();
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    end
end



ExplorerList.GetPath


(string) ExplorerList.GetPath ( 

(string) Object )

Description

Gets the current displayed directory.

Parameters

Object

(string) The name of the host object.

Returns

(string) The path of the current folder/drive, or a blank string ("") if no current folder.


Example

-- gets the current path and displays it in a dialog
local sPath = ExplorerList.GetPath("ListBox1");
if sPath ~= "" then
    Dialog.Message("ExplorerList","Current Path: "..sPath)
end



ExplorerList.SetPath


ExplorerList.SetPath ( 

(string) Object,

(string) Path )

Description

Sets the current displayed directory.

Parameters

Object

(string) The name of the host object.

Path

(string) The path to the folder to diaplay.

Note: The path must end with a lua backslash '\\'

Returns

This action dose not return any value.


Example

-- sets the current path to the project "Docs" folder
ExplorerList.SetPath("ListBox1", _SourceFolder.."\\AutoPlay\\Docs\\");



ExplorerList.GetSelectedItem


(string) ExplorerList.GetSelectedItem ( 

(string) Object )

Description

Gets the name of the currently select file or folder.

Parameters

Object

(string) The name of the host object.

Returns

(string) The name of the current selected file/folder, or a blank string ("") if no selection.


Example

-- gets the name of the current selected item and displays it in a dialog
local sItem = ExplorerList.GetSelectedItem("ListBox1");
if sItem ~= "" then
    Dialog.Message("ExplorerList","Current Item: "..sItem)
end



ExplorerList.GetSelectedItemType


(string) ExplorerList.GetSelectedItemType ( 

(string) Object )

Description

Gets the type of the currently select file or folder.

Parameters

Object

(string) The name of the host object.

Returns

(string) The type ('File' or 'Folder') of the current selected item, or a blank string ("") if no selection.


Example

-- gets the type of the current selected item and displays it in a dialog
local sItemType = ExplorerList.GetSelectedItemType("ListBox1");
if sItemType ~= "" then
    Dialog.Message("ExplorerList","Current Item Type: "..sItemType)
end



ExplorerList.SetPattern


ExplorerList.SetPattern ( 

(string) Object,

(string) Pattern )

Description

Sets the current file pattern.

Parameters

Object

(string) The name of the host object.

Pattern

(string) The file pattern ("*.lua;*.txt").

Note: can include one or multiple patterns, like "*.lua;*.txt".

Returns

This action dose not return any value.


Example

-- sets the display file pattern to "*.lua;*.txt;*.html"
ExplorerList.SetPattern("ListBox1", "*.lua;*.txt;*.html");



ExplorerList.SetDisplay


ExplorerList.SetDisplay ( 

(string) Object,

(number) Mode )

Description

Changes the display mode of the ExplorerList.

Parameters

Object

(string) The name of the host object.

Mode

(number) The mode to set.

Note: can include one or multiple patterns, like "*.lua;*.txt".

CONSTANT

VALUE

DESCRIPTION

ExplorerList_LargeIcon

NA

NA

ExplorerList_SmallIcon

NA

NA

ExplorerList_List

NA

NA

ExplorerList_Report

NA

NA

Returns

This action dose not return any value.


Example

-- sets the display mode to 'ExplorerList_Report' (default)
ExplorerList.SetDisplay("ListBox1", ExplorerList_Report);



ExplorerList.SetCallback


ExplorerList.SetCallback ( 

(string) Object,

(string) Function )

Description

Sets the objects callback function.

Parameters

Object

(string) The name of the host object.

Function

(string) The name of the callback function.

Returns

This action dose not return any value.


Example

--[[

The callback function exposes the following events:

OnSetFocus : sArgument = ""

OnKillFocus : sArgument = ""

OnHeaderClick : sArgument = Header index (use tonumber())

OnHeaderRightClick : sArgument = Header index (use tonumber())

OnRightClick : sArgument = Selected path or ""

OnRightDoubleClick : sArgument = Selected path or ""

OnDoubleClick : sArgument = Selected path or ""

OnClick : sArgument = Selected path or ""

OnKey : sArgument = KeyCode (use tonumber())

OnReturn : sArgument = Selected path or ""

OnDropFile : sArgument = Filepath

]]

Debug.ShowWindow();

function MyCallback(sObject, sEvent, sArgument)
    
    Debug.Print("Object="..sObject.." - Event="..sEvent.." - sArgument="..sArgument.."\r\n")

end

ExplorerList.SetCallback("ListBox1", "MyCallback");



ExplorerList.SetDropFiles


ExplorerList.SetDropFiles ( 

(string) Object,

(boolean) State )

Description

Enable or disable drop files.

Parameters

Object

(string) The name of the host object.

State

(boolean) True to enable drop files.

Returns

This action dose not return any value.


ExplorerList.GetSelectedItemTable


(table) ExplorerList.GetSelectedItemTable ( 

(string) Object )

Description

Gets a table of the selected items.

Parameters

Object

(string) The name of the host object.

Returns

(table) A table of the selected items, or nil if any error.

The table is indexed by the following values
Selected, The number if items that are selected.
Index, A table containing the item 0 based indexes.
Name, A table containing the item names.
Type, A table containing the item types ("File" or "Folder")


Example

-- get the selected items
tSelected=ExplorerList.GetSelectedItemTable("ListBox1");

if tSelected then

    local sOutput=""
    -- loop the selected items and show the result in a dialog.
    for nIndex=1, tSelected.Selected do
    
        sOutput=sOutput.."Index="..tSelected.Index[nIndex].." - Name="..tSelected.Name[nIndex].." - Type="..tSelected.Type[nIndex].."\r\n"
    
    end
    
    Dialog.Message("",sOutput)
    
end





This File Was Generated With AMS ActionFile Editor