[Solved] Menu Shortcut
BlitzMax Forums/MaxGUI Module/[Solved] Menu Shortcut
| ||
SuperStrict Import maxgui.Drivers Import brl.EventQueue Global Wello:TGadget = CreateWindow("ERROR", 100, 100, 500, 300) Global Menu:TGadget = CreateMenu("&Menu", 0, WindowMenu(Wello)) CreateMenu("Num&0", 1, Menu, KEY_NUM0, MODIFIER_COMMAND) CreateMenu("Num&1", 2, Menu, KEY_NUM1, MODIFIER_COMMAND) UpdateWindowMenu(Wello) Repeat WaitEvent() Select EventData() Case 1 SetStatusText(Wello, "KEY_NUM0") Case 2 SetStatusText(Wello, "KEY_NUM1") End Select Until EventID()=EVENT_WINDOWCLOSEWhen I build KEY_NUM0 become KEY_NUM1 and KEY_NUM1 become KEY_NUM2 What I do wrong? |
| ||
It is an error in a way MaxGUI is generating the string seen in a menu hotkey:m$="Num "+(keycode+1-KEY_NUM0)Maybe it shows correctly in some localizations, but not here (Scandinavian). -Henri |
| ||
So no fix for this then? |
| ||
You could modify MaxGUI source (win32maxguiex.bmx in Windows) ,take out the +1 and Rebuild all modules (requires MinGW, search forum for installation instructions). Are you in Windows enviroment ? -Henri |
| ||
Windows |
| ||
SOLUTION 1: (Tutorial for Windows, but same could be applied to others) Step 1. Open file win32maxguiex.bmx from MaxIDE editor's rightside panel. It's under +Projects / +Modules Source / +maxgui.mod / +win32maxguiex / win32maxguiex.bmx Modify this file a bit by adding a new method under TWindowsMenu type called... Method SetHotkeyText(pText$) _shortcut = "~t"+pText EndMethod...and save changes. Step 2. Next open file gadget.bmx which is found under +Projects / +Modules Source / +maxgui.mod / +maxgui.mod / gadget.bmx Modify this file a bit by adding a new method under TGadget (preferrably after SetText method) called.. Method SetHotkeyText(text$) End Method...and save changes Step 3. Make sure you have MinGW setup correctly. Step 4. From MaxIDE menu select Program / Build Modules. EXAMPLE OF USE: SuperStrict Import maxgui.Drivers Import brl.EventQueue Global Wello:TGadget = CreateWindow("ERROR", 100, 100, 500, 300) Global Menu:TGadget = CreateMenu("&Menu", 0, WindowMenu(Wello)) Local item1:tgadget = CreateMenu("Num&0", 1, Menu, KEY_NUM0, MODIFIER_COMMAND) Local item2:tgadget = CreateMenu("Num&1", 2, Menu, KEY_NUM1, MODIFIER_COMMAND) item1.SetHotkeyText("My custom menu shortcut1") item2.SetHotkeyText("My custom menu shortcut2") UpdateWindowMenu(Wello) Repeat WaitEvent() Select EventData() Case 1 SetStatusText(Wello, "KEY_NUM0") Case 2 SetStatusText(Wello, "KEY_NUM1") End Select Until EventID()=EVENT_WINDOWCLOSE |
| ||
Thank thee Henri your a true genius. What does TGadget gadget.bmx do? Method SetHotkeyText(text$) End MethodI erase this and it still works! I see the advantage to study all the maxgui .bmx files |
| ||
You probably didn't Build modules again after deleting. The method is only there to expose the method in TWindowsMenu type to user so that it's accessible through tgadget object which is what CreateMenu function returns. -Henri |