Maxscript:如何访问稍后在卷展栏中其他组中定义的 UI 控件(脚本插件)

发布于 2025-01-08 11:10:51 字数 629 浏览 0 评论 0原文

我有一个 simpleObject 脚本插件,在其中定义参数块及其关联的卷展栏:

rollout mainParamsRollout "Main Properties"
(
    group "Group1"
    (
        dropdownlist ddl1 "ddl1" items:#("A", "B") height:4
        on ddl1  selected i do
        (
            ddl2.enabled = false    
        )
    )

    group "Group2"
    (
        dropdownlist ddl2 "ddl2" items:#("C", "D") height:4
    )   
)

当我在 ddl1 上发生特定选择后尝试禁用 ddl2 时,maxscript 会抛出异常,指出 ddl2 未定义。

我知道可以通过 mainParamsRollout.controls[5] 访问 ddl2,但我想知道是否有更好的方法。我尝试在脚本化插件的顶部定义一个局部变量:

local ddl2

以使其在任何地方都可用,但这似乎也不起作用。有什么想法吗? 谢谢

I have a simpleObject scripted plug-in where I define a parameters block and its associated rollout:

rollout mainParamsRollout "Main Properties"
(
    group "Group1"
    (
        dropdownlist ddl1 "ddl1" items:#("A", "B") height:4
        on ddl1  selected i do
        (
            ddl2.enabled = false    
        )
    )

    group "Group2"
    (
        dropdownlist ddl2 "ddl2" items:#("C", "D") height:4
    )   
)

When I try to make ddl2 disabled after a certain selection happens on ddl1, maxscript throws an exception saying that ddl2 is undefined.

I know it is possible to access ddl2 though mainParamsRollout.controls[5] but I am wondering if there is a better way. I have tried defining a local variable at the top of the scripted plugin as:

local ddl2

to make it available anywhere but this does not seem to work either. Any ideas?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

揽清风入怀 2025-01-15 11:10:51

ddl1 的事件处理程序中调用ddl2 之前,必须声明它。您可以这样订购您的代码:

rollout mainParamsRollout "Main Properties"
(
    group "Group1"
    (
        dropdownlist ddl1 "ddl1" items:#("A", "B") height:4 
    )

    group "Group2"
    (
        dropdownlist ddl2 "ddl2" items:#("C", "D") height:4
    )   

    on ddl1 selected i do
    (
        ddl2.enabled = false    
    )
)

ddl2 must be declared before calling it in ddl1's event handler. You can order your code as such:

rollout mainParamsRollout "Main Properties"
(
    group "Group1"
    (
        dropdownlist ddl1 "ddl1" items:#("A", "B") height:4 
    )

    group "Group2"
    (
        dropdownlist ddl2 "ddl2" items:#("C", "D") height:4
    )   

    on ddl1 selected i do
    (
        ddl2.enabled = false    
    )
)
孤君无依 2025-01-15 11:10:51

或者只是在控件之前添加卷展栏,例如

mainParamsRollout.ddl.enabled = false

然后在哪里调用控件并不重要。

-约翰

Or just add the rollout before the control like

mainParamsRollout.ddl.enabled = false

Then it doesn't matter where you call the control.

-Johan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文