disable item in RC menu and in dropdownList menu

I have a RCmenu and It's working fine, but I don't know how to disable item in some circumstances

fn createMenu =
(
	rcMenu rcTest
	(
		menuItem miItem1 "name1"
		menuItem miItem2 "name2"
		menuItem miItem3 "name3"
		seperator menuSep01
		menuItem miItem4 "name4"
	)
        if a==0 then
           miItem1.enabled = false  --<<<<<< ??????????????????? >>>>>
        on miItem1 picked do  
	   print "1"
        ...
 
)

and a dropdownList menu where I want to disable items:

 dropdownList FilterSelect pos:[427,21] width:110 height:200
items:#("001", "002", "003", "004")
if a == 0 then item "002".enabled = false

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

:)

#2 examples by DenisT
enjoy!

try(form.close()) catch()
(
	global form = dotnetobject "MaxCustomControls.Maxform"
	form.ShowInTaskbar = form.MinimizeBox = form.MaximizeBox = off
	form.StartPosition = form.StartPosition.Manual
	form.Bounds = dotnetobject "System.Drawing.Rectangle" 800 200 100 60
 
	cm = dotNetObject "ContextMenu"
 
	fn onPopup s e = 
	(
		fn onClick s e = undo "Delete" on deletemodifier s.parent.tag.value s.tag.value
		for n in selection do
		(
			item = dotnetobject "MenuItem" n.name
			item.tag = dotnetmxsvalue n
			item.enabled = (n.modifiers.count > 0)
 
			for m in n.modifiers do
			(
				i = dotnetobject "MenuItem" m.name
				i.tag = dotnetmxsvalue m
				dotnet.addEventHandler i "Click" onClick
				item.menuitems.add i
			)
			s.menuitems.add item
		)
	)
	fn onCollapse s e = s.menuitems.Clear()
 
	dotnet.addEventHandler cm "Popup" onPopup
	dotnet.addEventHandler cm "Collapse" onCollapse
 
	form.ContextMenu = cm	
	form.showmodeless()
)		
 
(
	delete objects 
	for k=1 to 8 do
	(
		n = #(box, sphere, cylinder, cone)[random 1 4] pos:(random -[50,50,50] [50,50,50]) wirecolor:(random red green)
		for i=1 to (random 0 5) do addmodifier n (#(UVWmap, Unwrap_UVW, Edit_Poly, Edit_Normals, XForm)[random 1 5]())  
	)
	redrawviews()
)

barigazy

artrender.info's picture

BUT

Is it possible to add items?

barigazy's picture

...

I not like RCMenu but it's posible to disable a item. Never mind, let's continue with dd list

dropdownList FilterSelect pos:[427,21] width:110 height:200 items:#("001", "002", "003", "004")
 
testroll.FilterSelect.items = case a of
(
    (0): deleteItem testroll.FilterSelect.items (finditem testroll.FilterSelect.items "002")
    (1): deleteItem testroll.FilterSelect.items (finditem testroll.FilterSelect.items "004")
    (2): 
    (   
         local arr = testroll.FilterSelect.items
         appendIfUnique arr "005" ; sort arr
    )
    default:#("001", "002", "003", "004") -- if not used 0,1,2 or any other choise
)

barigazy

artrender.info's picture

ok!

I will try now!

artrender.info's picture

Thx Barigazy! Again YOUUUUUUUUU save me!

do you mean to remove items? Will this work for rcmenu also?

barigazy's picture

You can't disabled item in

You can't disabled item in dropdown list. But you can do this

--load on creation
dropdownList FilterSelect pos:[427,21] width:110 height:200
itmArr = case a of
(
    (0): #("001", "003", "004")
    (1): #("001", "002", "003")
)
FilterSelect.items = itmArr
 
-- or remove affter creation
--Let's say your rollout name is testroll
dropdownList FilterSelect pos:[427,21] width:110 height:200 items:#("001", "002", "003", "004")
 
testroll.FilterSelect.items = case a of
(
    (0): deleteItem testroll.FilterSelect.items (finditem testroll.FilterSelect.items "002")
    (1): deleteItem testroll.FilterSelect.items (finditem testroll.FilterSelect.items "004")
)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.