mik*_*itz 4 dialog window tidesdk
我正在开发一个TideSDK项目,我想为我的应用程序创建一个配置设置窗口,但我还没有看到任何关于如何在网站上或任何随附文档中执行此类操作的文档.
我熟悉Web开发,在浏览器中我会使用target = new(或类似的东西)来标记我想要在新窗口中打开url,但我还没有看到类似的东西.
我也尝试使用潮汐对话框功能,但看起来windows只适用于位于应用程序目录中的html文件(意味着它不会内置或与应用程序打包在一起).
这个功能在tidsdk中是否可用,或者我是否必须找到另一种设置/配置窗口的方法?
我查看了对话框功能,并找到了一种方法来完全按照你的意愿行事!API文档对此不是很清楚,我不得不尝试...
在主窗口中:
//Example function to apply configuration
function applyConfig(configObject){
setSomething(configObject.field);
...
}
//Create a dialog, and give it the above function as an `onclose` callback:
var dialog=Ti.UI.showDialog({url:"app://config.html",onclose:applyConfig});
Run Code Online (Sandbox Code Playgroud)
在config.html:
//An example of an object that could hold your config data
var config={field:0,example:"hello",...};
//Function to call in order to pass that object back to the main window callback:
Ti.UI.getCurrentWindow().close(config);
Run Code Online (Sandbox Code Playgroud)
所以......在你的主窗口中,你创建一个对话窗口,Ti.UI.showDialog并传递一个回调(params.onclose见上文).在对话框窗口中,一旦用户通过html界面设置了配置选项,您就可以将配置数据保存在对象中,并将其传递给窗口的close方法,并将其传递给主窗口中的回调.
Ti.UI.showDialog实际上调用Ti.UI.createWindow并返回一个Ti.UI.UserWindow对象,其中包含一些与对话框的参数,结果和onclose回调相关的字段和方法.
传递的对话框参数Ti.UI.showDialog({url:"...",parameters:{...}})可以使用Ti.UI.getCurrentWindow().getDialogParameter("name")或从对话框窗口中访问Ti.UI.getCurrentWindow()._dialogParameters["name"].
| 归档时间: |
|
| 查看次数: |
963 次 |
| 最近记录: |