---++!! !CommonCtrl.OpenFileDialog %TOC{title="Contents:"}% %STARTINCLUDE% ---++ Open File Dialog | *Title* | Open File Dialog | | *Author(s)* | LiXizhi | | *Date* | 2007/5/15 | | *File* | script/ide/OpenFileDialog.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/OpenFileDialog.lua"); local ctl = CommonCtrl.OpenFileDialog:new{ name = "OpenFileDialog1", alignment = "_ct", left=-256, top=-150, width = 512, height = 380, parent = nil, fileextensions = {"all files(*.*)", "images(*.jpg; *.png; *.dds)", "animations(*.swf; *.wmv; *.avi)", "web pages(*.htm; *.html)", }, folderlinks = { {path = "model/", text = "model"}, {path = "Texture/", text = "Texture"}, {path = "character/", text = "character"}, {path = "script/", text = "script"}, }, }; ctl:Show(true); -- external open using win32 dialog NPL.load("(gl)script/ide/OpenFileDialog.lua"); local filename = CommonCtrl.OpenFileDialog.ShowDialog_Win32(); if(filename) then commonlib.log(filename); end </verbatim> ---+++ Member Functions ---++++ !OpenFileDialog:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); local L = CommonCtrl.Locale("IDE"); define a new control in the common control libary default member attributes local OpenFileDialog = { -- the top level control name name = "OpenFileDialog1", -- the title to be displayed. title = nil, -- normal window size alignment = "_lt", left = 0, top = 0, width = 512, height = 290, -- TODO: how a dialog is poped up. if nil, it is just displayed as a top level window. -- If 1, it will gradually grey out the background and pops up with an animation. -- If 2, it will grey out the background and pops up WITHOUT animations. PopupStyle = 1, parent = nil, -- what kind of file extensions to load, the first one is always the default one. fileextensions = {"all files(*.*)", "images(*.jpg; *.png; *.dds)", "animations(*.swf; *.wmv; *.avi)", "web pages(*.htm; *.html)", }, -- at most four items folderlinks = { {folder = "model/", text = "model"}, {folder = "Texture/", text = "Texture"}, {folder = "character/", text = "character"}, {folder = "script/", text = "script"}, }, -- [used only internally] current folder, if nil, it will be the folder specifeid by the currentFolderlinkIndex currentFolder = nil, -- how many sub directory levels to show for the current folder. showSubDirLevels = 0, -- whether check the file existance CheckFileExists = true, -- event if CheckFileExists is true, we can specify a filename pass filter like "http://.*", so that the open file dialog will -- return when the user has specified a filename that contains could pass the specified filter. FileNamePassFilter = nil, -- initial file name to be displayed, usually "" FileName = "", -- appearance openInExplorerBtn_bg = "Texture/3DMapSystem/common/folder_go.png", deleteFileBtn_bg = "Texture/3DMapSystem/common/folder_delete.png", renameFileBtn_bg = "Texture/3DMapSystem/common/folder_edit.png", openAddFolderBtn_bg = "Texture/3DMapSystem/common/folder_add.png", main_bg = nil, -- use default container bg -- oncheck event, it can be nil, a string to be executed or a function of type void ()(sCtrlName, filename) onopen = nil, }</verbatim> CommonCtrl.OpenFileDialog = OpenFileDialog; constructor __syntax__ <verbatim>function OpenFileDialog:new (o)</verbatim> __parameters__ | *o* | | ---++++ !OpenFileDialog:Destroy Destroy the UI control __syntax__ <verbatim>function OpenFileDialog:Destroy ()</verbatim> ---++++ !OpenFileDialog.ShowDialog_Win32 use the external dialog * _param_ __filter__ : "All Files (*.*)\0*.*\0" * _return_ __the__ : filename selected or nil if nothing is selected or user clicked cancel. __syntax__ <verbatim>function OpenFileDialog.ShowDialog_Win32(filter)</verbatim> __parameters__ | *filter* | "All Files (*.*)\0*.*\0" | ---++++ !OpenFileDialog:Show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function OpenFileDialog:Show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !OpenFileDialog:Update update the UI according to the current selected folder and text __syntax__ <verbatim>function OpenFileDialog:Update()</verbatim> ---++++ !OpenFileDialog:GetFileName get the file name __syntax__ <verbatim>function OpenFileDialog:GetFileName()</verbatim> ---++++ !CommonCtrl.OpenFileDialog.OnClickFolder when a folder is clicked. __syntax__ <verbatim>function CommonCtrl.OpenFileDialog.OnClickFolder(self, filepath)</verbatim> __parameters__ | *self* | | | *filepath* | | ---++++ !CommonCtrl.OpenFileDialog.OnFileSelected select the file to file name box __syntax__ <verbatim>function CommonCtrl.OpenFileDialog.OnFileSelected(sCtrlName) </verbatim> __parameters__ | *sCtrlName* | | ---++++ !CommonCtrl.OpenFileDialog.OnFileSelectedAndOpen select and open file. called when double click on file. __syntax__ <verbatim>function CommonCtrl.OpenFileDialog.OnFileSelectedAndOpen(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !CommonCtrl.OpenFileDialog.OnClickOpenInExplorer open in external browser __syntax__ <verbatim>function CommonCtrl.OpenFileDialog.OnClickOpenInExplorer(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !CommonCtrl.OpenFileDialog.OnClickAddFolder TODO: add folder to current directory __syntax__ <verbatim>function CommonCtrl.OpenFileDialog.OnClickAddFolder(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !OpenFileDialog.OnClose close the given control __syntax__ <verbatim>function OpenFileDialog.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback