WebBrowserAppDev
description: 内嵌的Internet网页浏览器. 可以在3D世界中直接打开并操作网页。支持多种窗口模式和3D材质模式。应用程序开发商可以调用。
WebBrowser? app for Paraworld
| Title |
WebBrowser? app for Paraworld |
| Author(s) |
LiXizhi |
| Date |
2008/1/28 |
| File |
script/kids/3DMapSystemApp/WebBrowser/app_main.lua |
Description
WebBrowser?
other app can open an browser using this command with this app.
Map3DSystem.App.Commands.Call("File.WebBrowser", url);
File.MCMLBrowser
the second param can be a table of {name, title, url,
DisplayNavBar? , x,y, width, height, icon, iconsize}
Map3DSystem.App.Commands.Call("File.MCMLBrowser", {url="", name="MyBrowser", title="My browser", DisplayNavBar = true, DestroyOnClose=nil});
| name |
desc |
| url |
mcml url |
| name |
unique string of window name. |
| title |
boolean: show or hide the window |
| DisplayNavBar? |
true to display navigation bar |
| DestroyOnClose? |
default to nil. if true, it will destroy the window if user clicks close window button |
MCMLWindowFrame?
create and show a window frame using pure mcml. app_key is for which application the winframe is created if nil
WebBrowserApp? key is used. name is the window name.
-- show create
Map3DSystem.App.Commands.Call("File.MCMLWindowFrame", {url="", name="MyBrowser", app_key, bToggleShowHide=true, DestroyOnClose=nil, [win frame parameters]});
-- hide a window frame
Map3DSystem.App.Commands.Call("File.MCMLWindowFrame", {name="MyBrowser", app_key, bShow=false});
the second param can be a table with following field
| name |
desc |
| url |
mcml url |
| bShow |
boolean: show or hide the window |
| bDestroy |
if true, it will destroy the window |
| bToggleShowHide |
if true, it will toggle show hide |
| DestroyOnClose? |
default to nil. if true, it will destroy the window if user clicks close window button |
| [win frame parameters] |
all windowsframe property are support. |
WinExplorer?
Open a file or directory using default windows explorer.
Map3DSystem.App.Commands.Call("File.WinExplorer", "readme.txt");
-- silent mode.
Map3DSystem.App.Commands.Call("File.WinExplorer", {filename="readme.txt", silentmode=true]});
the second param can be a table with following field
| name |
desc |
| filepath |
it can be relative or absolute file path |
| silentmode |
boolean: if true, no dialog is displayed for confirmation. otherwise a dialog is displayed for confirmation. defrault to false. |
db registration insert script
INSERT INTO apps VALUES (NULL, 'WebBrowser_GUID', 'WebBrowser', '1.0.0', 'http://www.paraengine.com/apps/WebBrowser_v1.zip', 'YourCompany', 'enUS', 'script/kids/3DMapSystemApp/WebBrowser/IP.xml', '', 'script/kids/3DMapSystemApp/WebBrowser/app_main.lua', 'Map3DSystem.App.WebBrowser.MSGProc', 1);
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/WebBrowser/app_main.lua");
Member Functions
Map3DSystem.App.WebBrowser.OnConnection
requires
create class
commonlib.setfield("Map3DSystem.App.WebBrowser", {});
event handlers
OnConnection? method is the obvious point to place your UI (menus, mainbars, tool buttons) through which the user will communicate to the app.
This method is also the place to put your validation code if you are licensing the add-in. You would normally do this before putting up the UI.
If the user is not a valid user, you would not want to put the UI into the IDE.
- param app : the object representing the current application in the IDE.
- param connectMode : type of Map3DSystem? .App.ConnectMode.
syntax
function Map3DSystem.App.WebBrowser.OnConnection(app, connectMode)
parameters
| app |
the object representing the current application in the IDE. |
| connectMode |
|
Map3DSystem.App.WebBrowser.OnDisconnection
Receives notification that the Add-in is being unloaded.
syntax
function Map3DSystem.App.WebBrowser.OnDisconnection(app, disconnectMode)
parameters
Map3DSystem.App.WebBrowser.OnQueryStatus
This is called when the command's availability is updated
When the user clicks a command (menu or mainbar button), the
QueryStatus? event is fired.
The
QueryStatus? event returns the current status of the specified named command, whether it is enabled, disabled,
or hidden in the
CommandStatus? parameter, which is passed to the msg by reference (or returned in the event handler).
- param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
- param statusWanted : what status of the command is queried. it is of type Map3DSystem? .App.CommandStatusWanted
- return __ : returns according to statusWanted. it may return an integer by adding values in Map3DSystem? .App.CommandStatus.
syntax
function Map3DSystem.App.WebBrowser.OnQueryStatus(app, commandName, statusWanted)
parameters
| app |
|
| commandName |
The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". |
| statusWanted |
|
| return |
returns according to statusWanted. it may return an integer by adding values in Map3DSystem? .App.CommandStatus. |
Map3DSystem.App.WebBrowser.OnExec
message proc for
MCMLWindowFrame?
local function
MCMLWinFrameMSGProc? (window, msg)
if(msg.type ==
CommonCtrl.os.MSGTYPE.WM_CLOSE) then
if(window.DestroyOnClose) then
window:DestroyWindowFrame();
commonlib.echo(tostring(window.name).."closed")
else
window:ShowWindowFrame(false);
end
end
end
show
MCMLWindowFrame? in the parent window
- param bShow : boolean to show or hide. if nil, it will toggle current setting.
- param __ :_parent: parent window inside which the content is displayed. it can be nil.
- param parentWindow : parent os window object, parent window for sending messages
local function
MCMLWinFrameShow? (bShow, _parent, parentWindow)
local _this;
_this = _parent:GetChild("mcmlpage");
if(_this:IsValid())then
if(bShow==nil) then
bShow = not _this.visible;
end
_this.visible = bShow;
else
if(bShow == false) then return end
bShow = true;
_this =
CreateUIObject? ("container", "mcmlpage", "_fi", 0, 0, 0, 0)
_this.background = "";
_parent:AddChild(_this);
_parent = _this;
NPL.load("(gl)script/kids/3DMapSystemApp/mcml/PageCtrl.lua");
parentWindow.MyPage =
Map3DSystem? .mcml.PageCtrl:new({url=parentWindow.url});
parentWindow.MyPage:Create(tostring(_parent.id), _parent, "_fi", 0, 0, 0, 0)
end
end
This is called when the command is invoked.The Exec is fired after the
QueryStatus? event is fired, assuming that the return to the statusOption parameter of
QueryStatus? is supported and enabled.
This is the event where you place the actual code for handling the response to the user click on the command.
- param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
syntax
function Map3DSystem.App.WebBrowser.OnExec(app, commandName, params)
parameters
Map3DSystem.App.WebBrowser.OnRenderBox
Change and render the 3D world with mcml data that is usually retrieved from the current user's profile page for this application.
syntax
function Map3DSystem.App.WebBrowser.OnRenderBox(mcmlData)
parameters
Map3DSystem.App.WebBrowser.Navigate
called when the user wants to nagivate to the 3D world location relavent to this application
syntax
function Map3DSystem.App.WebBrowser.Navigate()
Map3DSystem.App.WebBrowser.GotoHomepage
called when user clicks to check out the homepage of this application. Homepage usually includes:
developer info, support, developer worlds information, app global news, app updates, all community user rating, active users, trade, currency transfer, etc.
syntax
function Map3DSystem.App.WebBrowser.GotoHomepage()
Map3DSystem.App.WebBrowser.DoQuickAction
called when user clicks the quick action for this application.
syntax
function Map3DSystem.App.WebBrowser.DoQuickAction()
Map3DSystem.App.WebBrowser.MSGProc
client world database function helpers.
all related messages
APPS can be invoked in many ways:
Through app Manager
mainbar or menu command or buttons
Command Line
3D World installed apps
syntax
function Map3DSystem.App.WebBrowser.MSGProc(window, msg)
parameters
a simple web browser
| Title |
a simple web browser |
| Author(s) |
LiXizhi |
| Date |
2007/10/29 |
| File |
script/kids/3DMapSystemApp/WebBrowser/BrowserWnd.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/WebBrowser/BrowserWnd.lua");
Map3DSystem.App.WebBrowser.BrowserWnd.BrowserName = "<html>";
Map3DSystem.App.WebBrowser.BrowserWnd.DisplayNavBar = true;
Map3DSystem.App.WebBrowser.BrowserWnd.Show(bShow,_parent,parentWindow)
Map3DSystem.App.WebBrowser.BrowserWnd.ShowWnd(_app)
Map3DSystem.App.WebBrowser.BrowserWnd.NavigateTo("http://www.paraengine.com");
Map3DSystem.App.WebBrowser.BrowserWnd.NavigateTo("local://readme.txt");
Member Functions
Map3DSystem.App.WebBrowser.BrowserWnd.ShowWnd
whether to display the nav bar
Map3DSystem? .App.WebBrowser.BrowserWnd.DisplayNavBar = true;
default browser window name. it should always begin with "", texture file with the same name will be bind to the web browser window.
Map3DSystem? .App.WebBrowser.BrowserWnd.BrowserName = "";
home page url
Map3DSystem? .App.WebBrowser.BrowserWnd.HomePageURL = "www.paraengine.com";
a file containing url addresses
Map3DSystem? .App.WebBrowser.BrowserWnd.UrlAddressesFile = "config/webbrowser_urls.txt";
private: internal use
Map3DSystem? .App.WebBrowser.BrowserWnd.LastStatusText = {}
display the main inventory window for the current user.
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.ShowWnd(_app)
parameters
Map3DSystem.App.WebBrowser.BrowserWnd.OnDestory
methods
destory the control
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.OnDestory()
Map3DSystem.App.WebBrowser.BrowserWnd.NavigateTo
go to a given url.
- param url : such as "www.paraengine.com", "http://www.lixizhi.net", it can also contain relative path like "local://Texture/3DMapSystem/HTML/Credits.html"
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.NavigateTo(url)
parameters
|
url | such as "www.paraengine.com", "http://www.lixizhi.net",
it can also contain relative path like "local://Texture/3DMapSystem/HTML/Credits.html" |
Map3DSystem.App.WebBrowser.BrowserWnd.windowPosToTexturePos
get the browser mouse cursor position by screen coordinate
- param UIObject : UI Window object
- param wnd : Browser texture window
- param screen :_x, screen_y : usually mouse_x, mouse_y from the "onmouseup" event handler
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.windowPosToTexturePos(UICtrl, wndBrowser, screen_x, screen_y)
parameters
| UICtrl |
|
| wndBrowser |
|
| screen |
_x, screen_y : usually mouse_x, mouse_y from the "onmouseup" event handler |
| x |
|
| screen |
_x, screen_y : usually mouse_x, mouse_y from the "onmouseup" event handler |
| y |
|
Map3DSystem.App.WebBrowser.BrowserWnd.LoadURLListFromFile
read URL list from a file and return a table containing those URLs.
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.LoadURLListFromFile(sFileName)
parameters
Map3DSystem.App.WebBrowser.BrowserWnd.OnMouseDown
window events
this determines whether we will change the cursor icon when mouse enter and leaves the browser window, since browser window will use its own cursor than the game engine.
Map3DSystem? .App.WebBrowser.BrowserWnd.UseSystemCursor =
GetUseSystemCursor? ();
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.OnMouseDown(browserName)
parameters
Map3DSystem.App.WebBrowser.BrowserWnd.OnKeyDown
this function is not called.Key events is directly sent to the window
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.OnKeyDown(browserName)
parameters
Map3DSystem.App.WebBrowser.BrowserWnd.OnClickNavForward
control methods
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.OnClickNavForward(browserName)
parameters
Map3DSystem.App.WebBrowser.BrowserWnd.onPageChanged
browser events
never called
syntax
function Map3DSystem.App.WebBrowser.BrowserWnd.onPageChanged()
a MCML browser window
| Title |
a MCML browser window |
| Author(s) |
LiXizhi |
| Date |
2008/4/28 |
| File |
script/kids/3DMapSystemApp/WebBrowser/MCMLBrowserWnd.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/WebBrowser/MCMLBrowserWnd.lua");
Map3DSystem.App.WebBrowser.MCMLBrowserWnd.ShowWnd(_app, {url="...", forcerefresh, name, title, zorder, DisplayNavBar, x,y, width, height, icon, iconsize, })
Member Functions
Map3DSystem.App.WebBrowser.MCMLBrowserWnd.ShowWnd
create
commonlib.setfield("Map3DSystem.App.WebBrowser.MCMLBrowserWnd", {});
Map3DSystem? .App.WebBrowser.MCMLBrowserWnd.InitParams = {};
display a
MCML browser window and goto its url.
- param __ :_app: the host app object
- param params : nil or a table containing following field {name, title, url, zorder, DisplayNavBar? , x,y, width, height, icon, iconsize, DestroyOnClose? =nil}
- return the : window object.
syntax
function Map3DSystem.App.WebBrowser.MCMLBrowserWnd.ShowWnd(_app, params)
parameters
| app |
|
| params |
|
| return |
window object. |
Map3DSystem.App.WebBrowser.MCMLBrowserWnd.MSGProc
normal windows messages here
syntax
function Map3DSystem.App.WebBrowser.MCMLBrowserWnd.MSGProc(window, msg)
parameters
world info page
| Title |
world info page |
| Author(s) |
LiXizhi |
| Date |
2008/6/22 |
| File |
script/kids/3DMapSystemApp/WebBrowser/OpenInBrowserDlgPage.lua |
Description
display a dialog asking the user whether to open url in external browser or internal browser.
"script/kids/3DMapSystemApp/WebBrowser/OpenInBrowserDlgPage.html?url=your_url_browser"
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/WebBrowser/OpenInBrowserDlgPage.lua");
Map3DSystem.App.WebBrowser.OpenInBrowserDlgPage.Show(url, x, y)
Member Functions
OpenInBrowserDlgPage.Show
show a top level popup window for a mouse cursor 3D mesh object
OpenInBrowserDlgPage? .Name = "OpenInBrowserDlg";
- param url : url to open. if nil, the window will be destroyed
- param x :,y: position at which to display the window. If nil, the center of screen is used.
syntax
function OpenInBrowserDlgPage.Show(url, x, y)
parameters
| url |
url to open. if nil, the window will be destroyed |
| x |
|
| y |
|
OpenInBrowserDlgPage.OnOpenInternal
open using internal browser
syntax
function OpenInBrowserDlgPage.OnOpenInternal()
OpenInBrowserDlgPage.OnOpenExternal
open using external system web browser, such as ie
syntax
function OpenInBrowserDlgPage.OnOpenExternal()
OpenInBrowserDlgPage.OnClose
open using external system web browser, such as ie
syntax
function OpenInBrowserDlgPage.OnClose()