try:
local myMenu = MenuElement({type = MENU, id = "main_menu", name = "Main Menu"})
myMenu:MenuElement({type = MENU, id = "main_menu_combo", name = "Combo"})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_key", name = "Combo Key", value = 0x20})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Smart Combo", type = PARAM, value = true})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Dumb Combo", type = PARAM, value = false})
Callback.Add('Tick', function()
if myMenu.main_menu_combo.main_menu_combo_key:Value() then
if myMenu.main_menu_combo.main_menu_combo_dumb:Value() then
--Do dumb stuff
end
end
end)
although i'd work on your naming conventions
The names were just for the purpose of this thread. But then I have to create a separate menu for the key?
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_key", name = "Combo Key", value = 0x20})
I thought key was a parameter any MenyElement could have and then I would test for that menu instance Value ( ) against some IS_KEY_DOWN constant.
So, for example, if I have something like: (I'll try to improve the names)
local harass_menu = main_menu:MenuElement ( { id = "main_menu_harass", name = "Harass", type = MENU } )
harass_menu:MenuElement ( { id = "main_menu_harass_harass_toggle",
name = "Harass Toggle",
type = PARAM,
value = false,
key = 0x41 } ) -- this is wrong, apparently
--bellow is the correct form, if I understood you correctly. But how do I assign a key to perform
--the same functionality as clicking the menu item (assuming clicking the MenuElement will indeed
--toggle it from false to true and vice-versa)
harass_menu:MenuElement ( { id = "main_menu_harass_harass_toggle",
name = "Harass Toggle",
type = PARAM,
value = false } )
In the code above, I make the following assumption: clicking a boolean MenuElement will toggle it.
How do I assign a key that will have the same effect as oppening the menu and clicking it?