How to create greyed out submenus?
BlitzMax Forums/MaxGUI Module/How to create greyed out submenus?
| ||
| This has to be simple, but the docs and the forums are coming up blank. All I need is a standard menu structure. Under 'File' for instance, the submenus would look something like this New Open Save Close I'd like to grey out 'Open' 'Save' and 'Close' but just can't find the commands. The commands DisableGadget(somemainmenu) will work, but only on the main menus (T:Gadgets), they won't work on submenus defined like this... CreateMenu "O&pen", MENU_PROJECTOPEN, filemenu Read on one of the threads about this command... EnableMenuItem() which isn't in the docs. Is there a working command that can disable submenu's or do any menus that need disabling have to be defined as menu gadgets? |
| ||
| Try : DisableMenu(menu:TGadget) |
| ||
| You may have to call UpdateWindowMenu() after DisableMenu() so that the status is updated on the screen. |
| ||
| Cheers guys, but that only works with the main menus. Sub-menus defined like this... "CreateMenu "O&pen", MENU_PROJECTOPEN, filemenu" , can't be called with the DisableMenu(menu:TGadget) command because it needs to be passed a TGadget. If I pass it the gadget name (in this case "file menu") it'll just grey out the main menu. It's just the some of the sub menu's I'd like to disable. |
| ||
| Local mainmenu:TGadget=WindowMenu(win) Local menu:TGadget=CreateMenu("Menu",101,mainmenu) You need to get the TGadget of the submenu and disable that one |
| ||
Righto, cheers, I haven't been creating the submenus with gadgets, I was using the basic examples from the docs which doesn't use sub menu gadgets, Is this out of date now then?
Local window:TGadget
Local filemenu:TGadget
window=CreateWindow("My Window",40,40,320,240)
filemenu=CreateMenu("&File",0,WindowMenu(window))
CreateMenu"&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND
CreateMenu"&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND
CreateMenu"&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND
CreateMenu"",0,filemenu
CreateMenu"&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND
CreateMenu"",0,filemenu
CreateMenu"E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND
Thanks for your help here chaps, I'll use the other way. |
| ||
| Righto, cheers, I haven't been creating the submenus with gadgets Ah, OK, that would explain the confusion... ;-) Is this out of date now then? Well, not really out of date, more that it's bad practice as you no longer have *any* references to the sub-menu just created with which you would use to disable/enable or free (delete) the menu. It's best practice to store a handle to all gadgets you create somewhere in your program. |
| ||
| Leans over and scribbles in notebook... "If you want to do it right, whatever you do, don't copy the docs" :D Cheers :) |
| ||
| There's a problem using UpdateWindowMenu inside loop: If we use PopupMenu ( for mouse context ) The contextMenu is droped as a "normal" Menu Only way I found is freeing the contextmenu, then Disable, Update and finally recreate the contextmenu... Did Anyone solve this problem ? |
| ||
| There's a problem using UpdateWindowMenu inside loop: If we use PopupMenu ( for mouse context ) The contextMenu is droped as a "normal" Menu Only way I found is freeing the contextmenu, then Disable, Update and finally recreate the contextmenu... Can you please post a working code example and I'll have a look into it for you? Seb |
| ||
Local win:TGadget = CreateWindow ("win" ,5,5,400,300,Null,WINDOW_MENU+WINDOW_TITLEBAR)
' WindowMenu
Local Menu:TGadget = CreateMenu ("Menu 1" ,01,win)
Local SubMenu:TGadget = CreateMenu ("Menu S1" ,11,Menu)
UpdateWindowMenu(win)
' PopupMenu
Local Popup:TGadget = CreateMenu ("Menu Pop",02,win) ' Here ! I have to set Parent to Null !!!
Local SubPopup:TGadget = CreateMenu ("UpdateWindowMenu",21,Popup)
HideGadget Popup
Local Pannel:TGadget=CreatePanel(5,5,380,250,win,PANEL_ACTIVE)
Local Event:Int=0
Repeat
Event=PollEvent()
Select Event
Case EVENT_WINDOWCLOSE
End
Case EVENT_MOUSEUP ; PopupWindowMenu(win,Popup)
Case EVENT_MENUACTION
Select CurrentEvent.data
Case 21 ; UpdateWindowMenu(win)
End Select
End Select
Forever
I think i found the problem the popupmenu must be created with no parent ( or everything but the window gadget ) replacing
Local Popup:TGadget = CreateMenu ("Menu Pop",02,win)
by
Local Popup:TGadget = CreateMenu ("Menu Pop",02,null)
seems to fix the problem. It's just I didn't take care about parenting menu to the good gadget ^^ |