if dir property is nil, it will open using external win32 file browser
local pe_fileupload = {};
Map3DSystem.mcml_controls.pe_fileupload = pe_fileupload;
Creates a file upload object with a text box and Browse button.
this is just a combo control.
syntax
function pe_fileupload.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_fileupload.OnClickBrowseBtn
click function
syntax
function pe_fileupload.OnClickBrowseBtn(name)
parameters
pe_fileupload.GetValue
get the MCML value on the node
syntax
function pe_fileupload.GetValue(mcmlNode)
parameters
pe_fileupload.SetValue
set the MCML value on the node
syntax
function pe_fileupload.SetValue(mcmlNode, value)
parameters
pe_fileupload.GetUIValue
get the UI value on the node
syntax
function pe_fileupload.GetUIValue(mcmlNode, pageInstName)
parameters
pe_fileupload.SetUIValue
set the UI value on the node
syntax
function pe_fileupload.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
all design related tags.
Title |
all design related tags. |
Author(s) |
LiXizhi |
Date |
2008/2/15 |
File |
script/kids/3DMapSystemApp/MCML/pe_design.lua |
Description
pe:dialog, pe:tabs, pe:tab-item(onclick=""), pe:canvas3d, pe:slide (interval=3 order="sequence"|"random"), pe:filebrowser(rootfolder="script" filter="*.lua;*.txt"), pe:treeview and pe:treenode
pe:tabs
addtional display attribute.
<pe:tabs name="LoginSettings">
<pe:tab-item text="ABC" selected="true">
</pe:tab-item>
<pe:tab-item text="EFG">
</pe:tab-item>
</pe:tabs>
pe:filebrowser
File browser sample code:
<pe:script>
function TestFileBrowser_onclick(name, filepath)
local filepath = document:GetPageCtrl():SetUIValue("filepath", filepath);
end
function TestFileBrowser_OnDoubleClick(name, filepath)
_guihelper.MessageBox(tostring(filepath));
end
</pe:script>
<input name="filepath">Please select from below</input><br/>
<pe:filebrowser name="myFileBrowser" filter="*.lua;*.txt" rootfolder="script" onclick="TestFileBrowser_onclick()" ondoubleclick="TestFileBrowser_OnDoubleClick()"></pe:filebrowser>
pe:canvas3d
properties src or value, rotSpeed, autoRotateSpeed, panSpeed, maxLiftupAngle, minLiftupAngle, maxZoomDist, minZoomDist, RenderTargetSize
objectbinding |
"selection", it binds to System.obj.GetObjectParams(objectbinding); |
Canvas3d sample code:
<pe:canvas3d name="canvas1">
{
name= "test model",
AssetFile= "model/05plants/01flower/01flower/flower10_v_a.x",
x=0,y=0,z=0,
}
</pe:canvas3d>
pe:treeview
this control will fill entire client area, such returned top is height. if child node is not pe:treenode, it is always
rendered inside an anonymous treenode using the default height all child nodes are created only when viewable.
properties:
pe:treenode
sub nodes of current pe:treenode are child tree nodes.
properties:
property |
description |
name |
|
selected |
"true" or "false", default to false |
text |
|
style |
height, color, font-weight, font-size are used |
icon |
|
height |
|
indent |
|
expanded |
|
invisible |
|
pe:slide
for images or text. It just changes a different page at a given interval.
properties: interval=10 order="sequence"|"random"
pe:progressbar
a progress bar with onstep callback. One can use SetUIValue and GetUIValue to modify the current progress.
Usually, one needs to call ForceRender() in onstep callback.
properties: Minimum = "0" Maximum = "100" Value = "0" Step = "10" onstep="AnyFunction"
onstep |
only called when step is reached. type of function(step) end |
sample code
<pe:progressbar name="MyProgress" onstep="MyFunction()"/>
<pe:progressbar name="MyProgress" Minimum = "0" Maximum = "100" Value = "0" Step = "10"/>
<pe:progressbar name="MyProgress" blockimage="Texture/3DMapSystem/Loader/progressbar_bg.png" background="Texture/3DMapSystem/Loader/progressbar_filled.png" Color="255 0 0"/>
pe:numericupdown
a numeric up down control is a text text plus spin buttons for inputing numeric values.
One can use SetUIValue and GetUIValue to modify the current value.
properties:
min |
default to 0 |
max |
default to 100 |
min_step |
default to nil, the minimum step value |
value |
default to nil |
valueformat |
such as "%.1f" |
style.background |
background of slider bar, it also includes the spin buttons. |
button_width |
spin button width, default to 16 (pixels). |
events
onchange |
onchange event, it can be nil, a string to be executed or a function of type void ()(value) |
sample code
<pe:numericupdown name="MyNumber" onchange="MyFunction()" min="0" max="100" min_step="1" value="0" valueformat="%.3f"/>
pe:sliderbar
a slider bar control using a button and a container: both vertical and horizontal slider is provided
One can use SetUIValue and GetUIValue to modify the current value.
properties:
min |
default to 0 |
max |
default to 100 |
min_step |
default to nil, the minimum step value |
value |
default to nil |
direction |
nil, "vertical" or "horizontal". If nil it will deduce from the width and height. |
style.background |
background of slider bar. |
button_bg |
slider button background |
button_width |
default to 16 (pixel). |
button_height |
default to 16 (pixel). |
events
onchange |
onchange event, it can be nil, a string to be executed or a function of type void ()(value) |
sample code
<pe:sliderbar name="MySlider" onchange="MyFunction()" min="0" max="100" value="0"/>
<pe:sliderbar name="MySlider1" onchange="MyFunction()" min="0" max="100" value="0" style="background:url(Texture/3DMapSystem/common/ThemeLightBlue/slider_background_16.png#4 8 4 7)" button_bg="Texture/3DMapSystem/common/ThemeLightBlue/slider_button_16.png" button_width="16" button_height="16"/>
pe:colorpicker
colorpicker control displays a color edit control with 3 sliderbars to adjust R,G,B value
One can use SetUIValue and GetUIValue to modify the current RGB value.
properties:
value |
can be in format "255 255 255" or "#FFFFFF", default to "255 255 255" |
style.background |
background of slider bar. |
style.width |
default to 182 |
style.height |
default to 72 |
events
onchange |
onchange event, it can be nil, a string to be executed or a function of type void ()(red, green, blue) |
sample code
<pe:colorpicker name="MyColorpicker" onchange="MyFunction()" value="128 64 255"/>
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/mcml/pe_design.lua");
Member Functions
pe_dialog.create
pe:dialog control
local pe_dialog = {};
Map3DSystem.mcml_controls.pe_dialog = pe_dialog;
syntax
function pe_dialog.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_tabs.create
pe:tabs control:
attribute <pe:tab-item onclick=""> where onclick is a function (tabpagename) end
local pe_tabs = {};
Map3DSystem.mcml_controls.pe_tabs = pe_tabs;
tab pages are only created when clicked.
syntax
function pe_tabs.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_tabs.OnClickTab
user clicks the tab button
syntax
function pe_tabs.OnClickTab(treeNode)
parameters
pe_tabs.GetValue
get the MCML value on the node. value is is the node name or text or index of the tab item node.
syntax
function pe_tabs.GetValue(mcmlNode)
parameters
pe_tabs.SetValue
set the MCML value on the node. value is is the node name or text or index of the tab item node.
syntax
function pe_tabs.SetValue(mcmlNode, value)
parameters
pe_tabs.GetUIValue
get the UI value on the node, value is the node name or text or index of the tab item node.
syntax
function pe_tabs.GetUIValue(mcmlNode, pageInstName)
parameters
pe_tabs.SetUIValue
set the UI value on the node
syntax
function pe_tabs.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_treeview.create
pe:treeview control:
local pe_treeview = {};
Map3DSystem.mcml_controls.pe_treeview = pe_treeview;
this control will fill entire client area, such returned top is height.
if child node is not pe:treenode, it is always rendered inside an anonymous treenode using the default height
all child nodes are created only when viewable.
syntax
function pe_treeview.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_treeview.Refresh
Public method: for pe:pager
- param bRefreshUI : if true it will refresh treeview UI. Otherwise it will just rebuilt the child nodes
- param ctl : the tree view control. If nil, it will grab it from mcmlNode. However, by explicitly specify it,we can update child nodes of a different root.
syntax
function pe_treeview.Refresh(mcmlNode, pageInstName, bRefreshUI, ctl)
parameters
mcmlNode |
|
pageInstName |
|
bRefreshUI |
if true it will refresh treeview UI. Otherwise it will just rebuilt the child nodes |
ctl |
|
pe_treeview.createTreeNode
append a child tree Node mcml node
syntax
function pe_treeview.createTreeNode(parentNode, mcmlNode, bindingContext)
parameters
parentNode |
|
mcmlNode |
|
bindingContext |
|
pe_treeview.DrawNodeHandler
draw tree node handler.
return nil or the new height if current node height is not suitable, it will cause the node to be redrawn.
syntax
function pe_treeview.DrawNodeHandler(_parent,treeNode)
parameters
pe_slide.create
pe:slide control: slide show control: for images or text
attribute: interval=10 order="sequence"|"random"
local pe_slide = {};
Map3DSystem.mcml_controls.pe_slide = pe_slide;
syntax
function pe_slide.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height,style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_slide.onframemove
event handler
syntax
function pe_slide.onframemove(instName, rootName)
parameters
pe_slide.refresh
refresh the inner controls.
- param mcmlNode : the node content to be displayed in side the slide. This is usually one of the child nodes of the pe_slide.
syntax
function pe_slide.refresh(rootName, mcmlNode, bindingContext, _parent, style, contentLayout)
parameters
rootName |
|
mcmlNode |
the node content to be displayed in side the slide. This is usually one of the child nodes of the pe_slide. |
bindingContext |
|
parent |
|
style |
|
contentLayout |
|
pe_filebrowser.create
pe:filebrowser control:
node properties: onclick, onselect, oncheck, oncreatenode, filter, rootfolder, AllowFolderSelection, DisableFolderExpand, HideFolder,CheckBoxes
local pe_filebrowser = {};
Map3DSystem.mcml_controls.pe_filebrowser = pe_filebrowser;
this control will fill entire client area
syntax
function pe_filebrowser.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_filebrowser.GetUIValue
get the UI value on the node
syntax
function pe_filebrowser.GetUIValue(mcmlNode, pageInstName)
parameters
pe_canvas3d.create
pe:canvas3d control:
node properties: src or value, rotSpeed, autoRotateSpeed, panSpeed, maxLiftupAngle, minLiftupAngle, maxZoomDist, minZoomDist, RenderTargetSize
local pe_canvas3d = {};
Map3DSystem.mcml_controls.pe_canvas3d = pe_canvas3d;
this control will fill entire client area
syntax
function pe_canvas3d.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_canvas3d.GetValue
get the MCML value on the node
syntax
function pe_canvas3d.GetValue(mcmlNode)
parameters
pe_canvas3d.SetValue
set the MCML value on the node
syntax
function pe_canvas3d.SetValue(mcmlNode, value)
parameters
pe_progressbar.create
pe:progressbar control
local pe_progressbar = {};
Map3DSystem.mcml_controls.pe_progressbar = pe_progressbar;
these theme can be changed externally
pe_progressbar.Default_blockimage = "Texture/3DMapSystem/Loader/progressbar_filled.png: 7 7 13 7"
pe_progressbar.Default_background = "Texture/3DMapSystem/Loader/progressbar_bg.png:7 7 6 6"
pe_progressbar.Default_color = "255 255 255"
pe_progressbar.Default_height = 32
create pager control for navigation
syntax
function pe_progressbar.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_progressbar.GetUIValue
get the UI value on the node
syntax
function pe_progressbar.GetUIValue(mcmlNode, pageInstName)
parameters
pe_progressbar.SetUIValue
set the UI value on the node
syntax
function pe_progressbar.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_progressbar.GetValue
get the MCML value on the node
syntax
function pe_progressbar.GetValue(mcmlNode)
parameters
pe_progressbar.SetValue
set the MCML value on the node
syntax
function pe_progressbar.SetValue(mcmlNode, value)
parameters
pe_sliderbar.create
pe:sliderbar control
local pe_sliderbar = {};
Map3DSystem.mcml_controls.pe_sliderbar = pe_sliderbar;
create pager control for navigation
syntax
function pe_sliderbar.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_sliderbar.GetUIValue
get the UI value on the node
syntax
function pe_sliderbar.GetUIValue(mcmlNode, pageInstName)
parameters
pe_sliderbar.SetUIValue
set the UI value on the node
syntax
function pe_sliderbar.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_sliderbar.GetValue
get the MCML value on the node
syntax
function pe_sliderbar.GetValue(mcmlNode)
parameters
pe_sliderbar.SetValue
set the MCML value on the node
syntax
function pe_sliderbar.SetValue(mcmlNode, value)
parameters
pe_numericupdown.create
pe:numericupdown control
local pe_numericupdown = {};
Map3DSystem.mcml_controls.pe_numericupdown = pe_numericupdown;
create pager control for navigation
syntax
function pe_numericupdown.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_numericupdown.GetUIValue
get the UI value on the node
syntax
function pe_numericupdown.GetUIValue(mcmlNode, pageInstName)
parameters
pe_numericupdown.SetUIValue
set the UI value on the node
syntax
function pe_numericupdown.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_numericupdown.GetValue
get the MCML value on the node
syntax
function pe_numericupdown.GetValue(mcmlNode)
parameters
pe_numericupdown.SetValue
set the MCML value on the node
syntax
function pe_numericupdown.SetValue(mcmlNode, value)
parameters
pe_colorpicker.create
pe:colorpicker control
local pe_colorpicker = {};
Map3DSystem.mcml_controls.pe_colorpicker = pe_colorpicker;
create pager control for navigation
syntax
function pe_colorpicker.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_colorpicker.GetUIValue
get the UI value on the node
syntax
function pe_colorpicker.GetUIValue(mcmlNode, pageInstName)
parameters
pe_colorpicker.SetUIValue
set the UI value on the node
syntax
function pe_colorpicker.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_colorpicker.GetValue
get the MCML value on the node
syntax
function pe_colorpicker.GetValue(mcmlNode)
parameters
pe_colorpicker.SetValue
set the MCML value on the node
syntax
function pe_colorpicker.SetValue(mcmlNode, value)
parameters
all controls for editor display controls.
Title |
all controls for editor display controls. |
Author(s) |
LiXizhi |
Date |
2008/2/15 |
File |
script/kids/3DMapSystemApp/MCML/pe_editor.lua |
Description
pe:editor,pe:container(alignment="_ctt") pe:editor-divider, pe:editor-buttonset, pe:editor-button(DefaultButton=true), pe:editor-custom, form
Button or input tag
Property |
Descriptions |
type |
"submit", "button", onclick event format is different for these two. |
onclick |
onclick callback of type function(btnName,mcmlNode) if type is not "submit" or function(btnName, values, bindingContext), if type is "submit". document object is available inside the function. |
tooltip |
mouse over tooltip |
enabled |
"true" or "false", whether to enable the button. |
DefaultButton |
boolean, default to false. if true it is the default button when enter is pressed. If type is submit, it is the default button by default. |
Special css property
background-rotation |
[-3.14, 3.14] |
note: if button type property is "submit", it must be inside a form tag, in order for its bindingcontext and values to take effect in its onclick event handler.
pe:container and pe:editor tags
only these tags support css right float and css vertical alignment, as well as alignment property e.g.
- style="float:right;vertical-align: bottom" is similar to "_rb" or right bottom in NPL. And it does not consume parent space.
- style="float:left;vertical-align: bottom" is similar to "_lb" or right bottom in NPL. And it does not consume parent space.
- style="float:right;" is similar to "_rt" or right top in NPL. And it does not consume parent space.
- alignment="_ctt", where the alignment property supports all NPL alignment types
- relation and visible style attributes are supported.
form tag
it is similar to html form tag except that the target property recoginizes mcml targets.
target property
It may be "_self", "_blank", "_mcmlblank", "[iframename]". if this property is specified, the href will be regarded as mcml page file even if it begins with http.
iframename can be any iframe control name, where the href mcml page will be opened. if it is "_self", it will be opened in the current page control.
if it is "_mcmlblank", it will be opened in a new popup mcml window.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/mcml/pe_editor.lua");
Member Functions
pe_editor.NewBinding
pe:editor and pe:container control
local pe_editor = {};
Map3DSystem.mcml_controls.pe_editor = pe_editor;
all temp bindings: a mapping from pe_editor instance name to its binding object.
pe_editor.allBindings = {};
create a new binding object with an editor instance name.
syntax
function pe_editor.NewBinding(instName, bindingContext)
parameters
pe_editor.GetBinding
get the binding context. the bindingContext.values is the data source, which is a table of name value pairs retrieved from the sub controls.
syntax
function pe_editor.GetBinding(instName)
parameters
pe_editor.create
create editor or pe_container
syntax
function pe_editor.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height,style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_editor.refresh
refresh the inner controls.
syntax
function pe_editor.refresh(rootName, mcmlNode, bindingContext, _parent, style, contentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
style |
|
contentLayout |
|
pe_editor_custom.create
pe:editor-custom control
local pe_editor_custom = {};
Map3DSystem.mcml_controls.pe_editor_custom = pe_editor_custom;
increase the top by height.
syntax
function pe_editor_custom.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_editor_buttonset.create
pe:editor-buttonset control
local pe_editor_buttonset = {};
Map3DSystem.mcml_controls.pe_editor_buttonset = pe_editor_buttonset;
increment left by the width of this button. Button width is sized according to text length.
the buttonset control takes up 26 pixels in height
syntax
function pe_editor_buttonset.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_editor_button.create
pe:editor-button control
local pe_editor_button = {};
Map3DSystem.mcml_controls.pe_editor_button = pe_editor_button;
a mapping from button name to mcml node instance.
pe_editor_button.button_instances = {};
the button control takes up 26 pixels in height, and button itself is 22 pixel height and has a default spacing of 5.
syntax
function pe_editor_button.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_editor_button.GetOnClickScript
get the onclick script based on the button node and bindingContext
- param instName : button instance name for the mcmlNode
- param mcmlNode : the mcml button node object
- param bindingContext : the bindingContext
- return __ : nil or the onclick script with heading ";"
syntax
function pe_editor_button.GetOnClickScript(instName, mcmlNode, bindingContext)
parameters
instName |
button instance name for the mcmlNode |
mcmlNode |
|
bindingContext |
the bindingContext |
pe_editor_button.GetValue
get the MCML value on the node
syntax
function pe_editor_button.GetValue(mcmlNode)
parameters
pe_editor_button.SetValue
get the MCML value on the node
syntax
function pe_editor_button.SetValue(mcmlNode, value)
parameters
pe_editor_button.GetUIValue
get the UI value on the node
syntax
function pe_editor_button.GetUIValue(mcmlNode, pageInstName)
parameters
pe_editor_button.SetUIValue
set the UI value on the node
syntax
function pe_editor_button.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_editor_button.OnGeneralClick
user clicks the button yet without form info
the callback function format is function(buttonName, mcmlNode) end
syntax
function pe_editor_button.OnGeneralClick(buttonName, callback, instName)
parameters
buttonName |
|
callback |
|
instName |
|
pe_editor_button.OnParamsClick
similar to pe_editor_button.OnGeneralClick except that the callback function is called with given parameters.
syntax
function pe_editor_button.OnParamsClick(callback, instName, ...)
parameters
pe_editor_button.OnClick
user clicks the normal button.
the callback function format is function(buttonName, values, bindingContext) end
syntax
function pe_editor_button.OnClick(editorInstName, buttonName, callback, instName)
parameters
editorInstName |
|
buttonName |
|
callback |
|
instName |
|
pe_editor_button.OnSubmit
user clicks the submit button. we will automatically post to url. Local server is not used.
- param buttonName :
- param editorInstName :
- param url : the HTTP get url
- param pageCtrlName : where to open the submitted page
syntax
function pe_editor_button.OnSubmit(editorInstName, buttonName, url, pageCtrlName)
parameters
editorInstName |
|
buttonName |
|
url |
the HTTP get url |
pageCtrlName |
|
pe_editor_text.create
pe:editor-text control
local pe_editor_text = {};
Map3DSystem.mcml_controls.pe_editor_text = pe_editor_text;
increment top by the height of the control.
the control takes up (22*rows) pixels in height, and editbox itself is 22 pixel height.
syntax
function pe_editor_text.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_editor_text.GetValue
get the MCML value on the node
syntax
function pe_editor_text.GetValue(mcmlNode)
parameters
pe_editor_text.SetValue
set the MCML value on the node
syntax
function pe_editor_text.SetValue(mcmlNode, value)
parameters
pe_editor_text.GetUIValue
get the UI value on the node
syntax
function pe_editor_text.GetUIValue(mcmlNode, pageInstName)
parameters
pe_editor_text.SetUIValue
set the UI value on the node
syntax
function pe_editor_text.SetUIValue(mcmlNode, pageInstName, value)
parameters
mcmlNode |
|
pageInstName |
|
value |
|
pe_editor_divider.create
pe:editor-divider control: just render a dummy gray line
local pe_editor_divider = {};
Map3DSystem.mcml_controls.pe_editor_divider = pe_editor_divider;
increment top by divider height, e.g. 5 pixels.
syntax
function pe_editor_divider.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
script related mcml node
Title |
script related mcml node |
Author(s) |
LiXizhi |
Date |
2008/4/15 |
File |
script/kids/3DMapSystemApp/mcml/pe_script.lua |
Description
pe:script, HTML script tag, e.g.
script tag
we can load external script or page embedded script(inline script). DOM object is exposed to both types of script for functions defined in them.
property
name |
description |
type |
default to "text/npl". currently there is only supported type. |
src |
external script file path |
refresh |
"true" or "false", default to "true". If true, when the pageCtrl:Refresh() method is called, the script block will reevaluate all inline scripts. Otherwise inline script are evaluated only once for a given page instance. |
[inner text] |
inline script |
external script
external script is loaded only once even if they appear in different page files. and it must be existing file on the local machine.
<pe:script type="text/npl" src="script/test/test.lua" />
embedded script
inline script is executed in place when the page is loaded. global functions and variables defined inside inline script are in a safe page environment.
therefore does not override the glia NPL scripting environment.
Example 1: short inline script
<%
varName = 123
function MyFuncion()
return "hello world"
end
document.write(MyFuncion());
%>
if script begins with =, it is same as document.write().
Example 2: one line script
<%=Eval("varName").."Hello world"%>
Example 3: verbose inline script
<script type="text/npl" refresh="true">
<![CDATA[
function InlineFunction()
return "function can be declared globally in a page environment"
end
document.write("<p>Hello "..InlineFunction())
document.write(commonlib.getfield("Map3DSystem.User.Name"))
document.write("!</p>")
]__REMOVE_THIS_COMMENT__]>
</script>
Note: there is an limitation of what can be inside an inline script. Inline script is evaluabled just in place at render time and does not modify the parent MCML node structure.
So generally only pure display MCML tags can be generated on the fly, like the one in above example. Forms and id requery is not possible for dynamically generated node.
Note: both inline and external scripts are currently in global environment. We will restrict access to some classes in future,
so do not attempt to modify anything global in it, otherwise your code may become invalid after the upcoming patch.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/mcml/pe_script.lua");
Map3DSystem.mcml_controls.pe_script.BeginCode(mcmlNode);
NPL.DoString(code);
Map3DSystem.mcml_controls.pe_script.EndCode(parentLayout);
Member Functions
pe_script.create
pe:script and html script node
local pe_script = {};
Map3DSystem.mcml_controls.pe_script = pe_script;
the following code is appended before the actual code to prevent global function defined in inline script to pollute the global environment.
pe_script.prepare_page_env = "setfenv (1, Map3DSystem.mcml_controls.pe_script._PAGESCRIPT);";
Code within this element is executed immediately when the page is loaded, if it is not in a function.
if it references an external script. The script should be on disk, otherwise it will be ignored.
Moreover, external script will be loaded only once. e.g.
MCML also supports Embedded Code Blocks in MCML Pages. The syntax is <%embeded code block%>. An embedded code block is server code that
executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class.
Embedded code blocks must be written in the page's default language.
In general, using embedded code blocks for complex programming logic is not a best practice, because when the code is mixed on the page with markup,
it can be difficult to debug and maintain. In addition, because the code is executed only during the page's render phase,
you have substantially less flexibility than with code-behind or script-block code in scoping your code to the appropriate stage of page processing.
-- There is also a short cut <%="Any text or function here"%> which expands to <%document.write("Any text or function here")%>,
e.g. one can write <%="profile.xml?uid="+Eval("uid")%>
syntax
function pe_script.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height,style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
|
pe_script.DoPageCode
Execute code in page scoping and return the result of the code.
- param code : string to do, please note: page document object is not available in code There is also a short cut ="Any text or function here", which expands to return ("Any text or function here"), e.g. one can call pe_script.DoPageCode("=\"profile.xml?uid=\"+Eval(\"uid\")") as short cut for pe_script.DoPageCode("return (\"profile.xml?uid=\"+Eval(\"uid\"))")
- return __ : code result is returned.
syntax
function pe_script.DoPageCode(code, pageCtrl)
parameters
| code | string to do,
please note: page document object is not available in code
There is also a short cut ="Any text or function here", which expands to return ("Any text or function here"),
e.g. one can call pe_script.DoPageCode("=\"profile.xml?uid=\"+Eval(\"uid\")") as short cut for pe_script.DoPageCode("return (\"profile.xml?uid=\"+Eval(\"uid\"))") |
pe_script.PageScope.Eval
page scope functions
pe_script.PageScope = {};
evaluate a variable only in current page scope.
- param name : name of the value to be searched in page environment.
syntax
function pe_script.PageScope.Eval(name)
parameters
name |
name of the value to be searched in page environment. |
pe_script.PageScope.XPath
evaluate a variable hierarchy only in current page scope.
- param name : name of the value to be searched in page environment. such as "Book/Title", "Book.Title"
syntax
function pe_script.PageScope.XPath(name)
parameters
name |
name of the value to be searched in page environment. such as "Book/Title", "Book.Title" |
pe_script.SetPageScope
set page scope for the given page
so that Map3DSystem.mcml_controls.pe_script._PAGESCRIPT contains the page environment
a page scope contains all functions in pe_script.PageScope. The most important one is Eval(name), XPath(name) and Page object.
syntax
function pe_script.SetPageScope(pageCtrl)
parameters
pe_script.BeginCode
code executed between pe_script.BeginCode() and pe_script.EndCode() can access to the "document" DOM object.
setup the DOM environment so that we can do something like below inside inline script block.
- param mcmlNode : must be a valid node which provide the context of the mcml page.
syntax
function pe_script.BeginCode(mcmlNode)
parameters
mcmlNode |
must be a valid node which provide the context of the mcml page. |
pe_script.EndCode
code executed between pe_script.BeginCode() and pe_script.EndCode() can access to the "document" DOM object.
- param parentLayout : if not nil, it will create
syntax
function pe_script.EndCode(rootName, mcmlNode, bindingContext, _parent, left, top, width, height,style, parentLayout)
parameters
rootName |
|
mcmlNode |
|
bindingContext |
|
parent |
|
left |
|
top |
|
width |
|
height |
|
style |
|
parentLayout |
if not nil, it will create |