Digitalmicrograph DM 脚本 - 从另一个对话框更新下拉项目
Digitalmicrograph DM script - updating pulldown items from another dialog
我正在开发一个 DM 脚本,该脚本创建了一种包含几个对话框的技术。
在此脚本中,我试图从另一个对话框中更新一个对话框中的下拉菜单项。
我目前在对话框中有一个带有下拉菜单的按钮,称为“更新”,它调用对话框 class 中称为“updateDialog”的函数。
此函数删除所有下拉菜单项,然后插入存储在标签列表中的所有项目。
它还会更改该对话框中几个按钮的状态。
这个更新按钮工作得很好。
现在,如果我从另一个对话框中调用此 updateDialog 函数,按钮状态会按预期更改,但下拉菜单不会更新。
有谁知道为什么会发生这种情况and/or是否有办法使它起作用?
谢谢!
示例代码:
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, dialogitems, dropdown, updatebutton, statebutton
dialog = DLGCreateDialog("second_dialog", dialogItems)
taggroup initial_items
dropdown = DLGCreateChoice(initial_items,0,"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, taskID, bEssential, bOpenByDefault )
AddCustomTechnique( technique )
}
main()
不是答案(还),而是更长的澄清评论
我正在 GMS 3.4.2 上测试您的脚本代码,这是我看到的行为,运行 GMS 启动后的脚本(一次):
这不正是预期的行为吗?
我正在开发一个 DM 脚本,该脚本创建了一种包含几个对话框的技术。 在此脚本中,我试图从另一个对话框中更新一个对话框中的下拉菜单项。
我目前在对话框中有一个带有下拉菜单的按钮,称为“更新”,它调用对话框 class 中称为“updateDialog”的函数。 此函数删除所有下拉菜单项,然后插入存储在标签列表中的所有项目。 它还会更改该对话框中几个按钮的状态。
这个更新按钮工作得很好。
现在,如果我从另一个对话框中调用此 updateDialog 函数,按钮状态会按预期更改,但下拉菜单不会更新。
有谁知道为什么会发生这种情况and/or是否有办法使它起作用?
谢谢!
示例代码:
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, dialogitems, dropdown, updatebutton, statebutton
dialog = DLGCreateDialog("second_dialog", dialogItems)
taggroup initial_items
dropdown = DLGCreateChoice(initial_items,0,"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, taskID, bEssential, bOpenByDefault )
AddCustomTechnique( technique )
}
main()
不是答案(还),而是更长的澄清评论
我正在 GMS 3.4.2 上测试您的脚本代码,这是我看到的行为,运行 GMS 启动后的脚本(一次):
这不正是预期的行为吗?