问题描述
我正在研究DM脚本,该脚本创建了一种包含一些对话框的技术。 在此脚本中,我试图从另一个对话框中更新一个对话框中的下拉菜单项。
我目前在对话框中有一个按钮,其下拉菜单名为“ update”,它在对话框类中调用了一个名为“ updateDialog”的函数。 此功能删除所有下拉菜单项,然后插入存储在标记列表中的所有项。 它还会更改该对话框中几个按钮的状态。
此更新按钮效果很好。
现在,如果我从另一个对话框中调用此updateDialog函数,则按钮状态将按其应有的方式更改,但下拉菜单不会更新。
有人知道为什么会这样和/或是否有办法使它起作用吗?
谢谢!
示例代码:
taggroup menuitems = newtaglist()
object firstdialog,seconddialog
interface I_seconddialog{
void updatedropdowndialog(object self);
}
class firstdialog : uiframe{
void additemresponse (object self){
number items = menuitems.taggroupcounttags()+1
menuitems.taggroupinserttagasstring(infinity(),"Created item #"+items)
menuitems.taggroupopenbrowserwindow(0)
seconddialog.updatedropdowndialog()
}
taggroup createdialog (object self){
taggroup dialog,dialogitems,additembutton
dialog = DLGCreateDialog("first_dialog",dialogItems)
additembutton = DLGCreatePushButton("Add pulldown item","additemresponse")
dialogitems.dlgaddelement(additembutton)
return dialog
}
object init (object self){
return self.super.init( self.createdialog() )
}
}
class seconddialog : uiframe{
number isbuttonenabled
void updatedropdowndialog (object self){
// Change the state of the state button to show that that does work
isbuttonenabled = abs(isbuttonenabled-1)
self.Setelementisenabled("statebutton",isbuttonenabled);
// Empty the dropdown as the menuitems list might be completely different
taggroup dropdown = self.lookupelement("dropdown")
taggroup dropdown_items
dropdown.taggroupgettagastaggroup("Items",dropdown_items)
dropdown_items.taggroupdeletealltags()
// Add the current tags in menuitems to the dropdown
for(number i=0;i<menuitems.taggroupcounttags();i++){
string item_name
menuitems.taggroupgetindexedtagasstring(i,item_name)
dropdown.dlgaddchoiceitementry(item_name)
}
}
taggroup createdialog (object self){
taggroup dialog,dropdown,updatebutton,statebutton
dialog = DLGCreateDialog("second_dialog",dialogItems)
taggroup initial_items
dropdown = DLGCreateChoice(initial_items,"dropdownchange").dlgidentifier("dropdown")
dropdown.dlgaddchoiceitementry("Initial item")
updatebutton = DLGCreatePushButton("Update dropdown","updatedropdowndialog")
statebutton = DLGCreatePushButton("state changes","stateresponse").dlgidentifier("statebutton")
dialogitems.dlgaddelement(dropdown)
dialogitems.dlgaddelement(updatebutton)
dialogitems.dlgaddelement(statebutton)
return dialog
}
object init (object self){
isbuttonenabled = 1
return self.super.init( self.createdialog() )
}
}
void main(){
String techniqueName = "Example"
Image techniqueIcon := RGBImage( "Test icon",4,75,75 )
techniqueIcon = RGB( icol,irow,iradius )
object technique = CreateTechnique( techniqueName,techniqueIcon )
firstdialog = Alloc( firstdialog ).Init()
String taskName = "First dialog"
Number taskID = RegisterWorkflowTask( firstdialog,taskName )
Number bOpenByDefault = 1
Number bEssential = 0
AddWorkflowTask( technique,taskID,bEssential,bOpenByDefault )
seconddialog = Alloc( seconddialog ).Init()
taskName = "Second dialog"
taskID = RegisterWorkflowTask( seconddialog,taskName )
bOpenByDefault = 1
bEssential = 0
AddWorkflowTask( technique,bOpenByDefault )
AddCustomTechnique( technique )
}
main()