CommonCtrl
common control shared lib
Title |
common control shared lib |
Author(s) |
LiXizhi |
Date |
2006/5/29 |
File |
script/ide/common_control.lua |
Description
Sample Code
NPL.load("(gl)script/ide/common_control.lua");
Member Functions
CommonCtrl.AddControl
common control library
if(not
CommonCtrl) then
CommonCtrl={}; end
if(not
CommonCtrl.allcontrols) then
CommonCtrl.allcontrols={}; end
add a new global control
syntax
function CommonCtrl.AddControl(sControlName,ctl)
parameters
CommonCtrl.DeleteControl
destroy and delete a global control. It will call the controll's Destroy() method if it exists
syntax
function CommonCtrl.DeleteControl(sControlName)
parameters
CommonCtrl.GetControl
get control by name. return nil if control not found
syntax
function CommonCtrl.GetControl(sControlName)
parameters
CommonCtrl.NewSubControlName
in case,
NewSubControlName's parentCtl is nil, this table ctl is used.
DefaultNameCtl = {name = "gCtrl"};
create a new unqiue sub control name based on the parent ctl object.
usually used for controls like tree view that needs to dynamically create a large number of sub controls whose name needs to unique
however, creating a unique name each sub control will pollute the global environment. Using
NewSubControlName and
ReleaseSubControlName to generate
control names will reuse control names as much as possible while ensuring that all visible control names are unique.
- param parentCtl : the parent control object. If nil, a global unnamed table is used.
- return __ : a unique name is returned. the name is (parentCtl.name or parentCtl.Name).."."..nNextEmptyIndex
syntax
function CommonCtrl.NewSubControlName(parentCtl)
parameters
parentCtl |
the parent control object. If nil, a global unnamed table is used. |
CommonCtrl.ReleaseSubControlName
when a sub control is not used, one needs to explicitly call this function to make its name reusable by newly created controls later on.
- param parentCtl : the parent control object.
- param subCtlName : the sub control name.
syntax
function CommonCtrl.ReleaseSubControlName(parentCtl, subCtlName)
parameters
parentCtl |
the parent control object. |
subCtlName |
|
CommonCtrl.DeleteAllSubControls
delete all sub controls, whose name is created by
NewSubControlName. Usually used by
TreeView class during update.
syntax
function CommonCtrl.DeleteAllSubControls(parentCtl)
parameters
Topic revision: r1 - 2008-02-29
- LiXizhi