如果这是基本的,我很抱歉。我是自学成才,并且对可能是 Javascript 编程的简单功能感到困惑。谁能告诉我我应该寻找什么来找到正确的答案,或者帮助我解决这个问题?
我在 UI 窗口中有一个函数,可以用面板快速填充它。但我似乎无法让输入到每个面板中的值从 UI 中移出并进入主“DoSomething”功能。
变量 (dlg.tryThis) 不会更新?为什么?我需要做什么?
// making a simple UI
function UI_Builder(doSomething)
{
var dlg = new Window( "dialog", "options" );
dlg.mainGroup = dlg.add( "group", undefined,"main" );
//Created a simple function so I can re-create panels and values very easy
function makePanel (panelName, val) {
var newPanel = eval("dlg.mainGroup." + panelName);
newPanel = dlg.mainGroup.add( 'panel', undefined, panelName );
newPanel.Start = newPanel.add("edittext", [0,0,30,20], val);
dlg.Start = newPanel.Start.text
newPanel.Start.onChanging = function()
{
dlg.Start = newPanel.Start.text
alert("Changed " + panelName + " to: " + dlg.Start) // THIS alerts correctly. It know what value I changed and where I changed it.
return dlg.Start;
}
return dlg.Start;
}
// calling the function to create panels.
dlg.tryThis = makePanel("tryThis", 4);
dlg.anotherOne = makePanel("anotherOne", 3);
dlg.again = makePanel("again", 2);
dlg.mainGroup.btnCancel = dlg.mainGroup.add( "button",[0,0,130,70], "doSomething" );
dlg.mainGroup.btnCancel.onClick = function()
{
doSomething();
}
return dlg
}
// all the UI builder is doing is showing the UI
var dlg = UI_Builder(doSomething);
dlg.show();
function doSomething()
{
dlg.close();
alert(dlg.tryThis) // this is not the NEW value? How do I get it to be the NEW value updated by the ".onChanging" function?
}