添加多个按钮且可见时出现 UserControl 问题 属性
UserControl issue when adding multiple buttons and visible property
这是一个已知问题,在 Maxsript 的 dotNet 中可见性被破坏。这里的 thread 展示了如何将按钮添加到 UserControl
以使其正常工作。
我的问题是我想向 UserControl
添加多个按钮,一旦我知道要取消隐藏哪个不在这个版本中,就将按钮移动到位,但这是我的意图,因为我需要这个功能。
第二个按钮没有显示,即使它的位置对于听众来说是正确的。
我希望我不必为每个按钮添加单独的 UserControl
!
如何向控件添加多个按钮并让它们更新它们的位置和可见性?
clearListener()
try destroyDialog RollsRoyce catch()
rollout RollsRoyce "" width:400 height:60
(
local btnH = 33
local btnW = RollsRoyce.width/2
dotnetcontrol panelVisibleFix "UserControl" width:RollsRoyce.width height:btnH pos:[0,15]
dotNetControl btn1 "button" text:"Button 1..." visible:false width:btnW height:btnH
dotNetControl btn2 "button" text:"Button 2..." visible:false width:btnW height:btnH
on RollsRoyce open do
(
btn1.FlatStyle = btn1.FlatStyle.System
btn2.FlatStyle = btn2.FlatStyle.System
panelVisibleFix.controls.addrange #(btn1, btn2)
-- Add the button to the panel and unhide it.
-- In my main script I want to check for conditions to have these visible or
-- not but with this simple example I want to unhide then.
btn1.visible = true
RollsRoyce.btn1.pos = panelVisibleFix.pos
-- This button is not getting shown.
btn2.visible = true
RollsRoyce.btn2.pos = RollsRoyce.panelVisibleFix.pos+[RollsRoyce.btnW,0]
format "btn1 position is: %\n" RollsRoyce.btn1.pos
format "btn2 position is: %\n" RollsRoyce.btn2.pos
)
)
createdialog RollsRoyce
您正在使用转出控件,就好像它们是常规 .NET 控件一样,并且您正在设置它们在转出上下文中的位置,就像您将其设置在 .NET 控件内一样。要么做一件事,要么做另一件事。在 rollout 控件中使用 .NET 控件,它可能看起来像这样的示例:
try destroyDialog RollsRoyce catch()
rollout RollsRoyce "" width:400 height:60
(
local btnH = 33
dotNetControl panelVisibleFix "FlowLayoutPanel" width:RollsRoyce.width height:btnH pos:[0,15]
fn makeNETBtn width height text visible:on =
(
local btn = dotNetObject "Button"
btn.Text = text
btn.Width = width
btn.Margin = dotNetObject "Padding" 0 0 0 0
btn.Height = height
btn.FlatStyle = btn.FlatStyle.System
btn.Visible = visible
return btn
)
on RollsRoyce open do
(
local btnW = RollsRoyce.width / 2
local btn1 = makeNETBtn btnW btnH "Button 1..." visible:off
local btn2 = makeNETBtn btnW btnH "Button 2..." visible:off
panelVisibleFix.Controls.AddRange #(btn1, btn2)
btn1.visible = on
btn2.visible = on
)
)
createDialog RollsRoyce
这是一个已知问题,在 Maxsript 的 dotNet 中可见性被破坏。这里的 thread 展示了如何将按钮添加到 UserControl
以使其正常工作。
我的问题是我想向 UserControl
添加多个按钮,一旦我知道要取消隐藏哪个不在这个版本中,就将按钮移动到位,但这是我的意图,因为我需要这个功能。
第二个按钮没有显示,即使它的位置对于听众来说是正确的。
我希望我不必为每个按钮添加单独的 UserControl
!
如何向控件添加多个按钮并让它们更新它们的位置和可见性?
clearListener()
try destroyDialog RollsRoyce catch()
rollout RollsRoyce "" width:400 height:60
(
local btnH = 33
local btnW = RollsRoyce.width/2
dotnetcontrol panelVisibleFix "UserControl" width:RollsRoyce.width height:btnH pos:[0,15]
dotNetControl btn1 "button" text:"Button 1..." visible:false width:btnW height:btnH
dotNetControl btn2 "button" text:"Button 2..." visible:false width:btnW height:btnH
on RollsRoyce open do
(
btn1.FlatStyle = btn1.FlatStyle.System
btn2.FlatStyle = btn2.FlatStyle.System
panelVisibleFix.controls.addrange #(btn1, btn2)
-- Add the button to the panel and unhide it.
-- In my main script I want to check for conditions to have these visible or
-- not but with this simple example I want to unhide then.
btn1.visible = true
RollsRoyce.btn1.pos = panelVisibleFix.pos
-- This button is not getting shown.
btn2.visible = true
RollsRoyce.btn2.pos = RollsRoyce.panelVisibleFix.pos+[RollsRoyce.btnW,0]
format "btn1 position is: %\n" RollsRoyce.btn1.pos
format "btn2 position is: %\n" RollsRoyce.btn2.pos
)
)
createdialog RollsRoyce
您正在使用转出控件,就好像它们是常规 .NET 控件一样,并且您正在设置它们在转出上下文中的位置,就像您将其设置在 .NET 控件内一样。要么做一件事,要么做另一件事。在 rollout 控件中使用 .NET 控件,它可能看起来像这样的示例:
try destroyDialog RollsRoyce catch()
rollout RollsRoyce "" width:400 height:60
(
local btnH = 33
dotNetControl panelVisibleFix "FlowLayoutPanel" width:RollsRoyce.width height:btnH pos:[0,15]
fn makeNETBtn width height text visible:on =
(
local btn = dotNetObject "Button"
btn.Text = text
btn.Width = width
btn.Margin = dotNetObject "Padding" 0 0 0 0
btn.Height = height
btn.FlatStyle = btn.FlatStyle.System
btn.Visible = visible
return btn
)
on RollsRoyce open do
(
local btnW = RollsRoyce.width / 2
local btn1 = makeNETBtn btnW btnH "Button 1..." visible:off
local btn2 = makeNETBtn btnW btnH "Button 2..." visible:off
panelVisibleFix.Controls.AddRange #(btn1, btn2)
btn1.visible = on
btn2.visible = on
)
)
createDialog RollsRoyce