SuperStrict
Const MENU_FILE_NEWMAP% = 1
Const MENU_FILE_SAVEMAP% = 2
Const MENU_FILE_LOADMAP% = 3
Const MENU_FILE_EXIT% = 4
Type TApp
Field mainWindow:TGadget
Field mainFileMenu:TGadget
Field otherWindow:TGadget
Method OnEvent(event:TEvent)
Select event.id
Case EVENT_WINDOWCLOSE
If event.source = mainWindow Then End
If event.source = otherWindow Then HideGadget otherWindow
Case EVENT_MENUACTION
Select event.data
Case MENU_FILE_NEWMAP
ShowGadget otherWindow
Case MENU_FILE_EXIT
End
End Select
End Select
End Method
Function EventHook:Object(id%, data:Object, context:Object)
Local event:TEvent = TEvent(data)
Local app:TApp = TApp(context)
app.OnEvent event
End Function
Method New()
mainWindow = CreateWindow("Wisp Engine Editor", 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()))
MaximizeWindow(mainWindow)
otherWindow = CreateWindow("Register",0,0,320,240,mainWindow ,65)
mainFileMenu = CreateMenu("&File", 0, WindowMenu(mainWindow))
CreateMenu("New &Map...", MENU_FILE_NEWMAP, mainFileMenu, KEY_M, MODIFIER_COMMAND)
CreateMenu("", 0, mainFileMenu)
CreateMenu("&Save Map", MENU_FILE_SAVEMAP, mainFileMenu, KEY_S, MODIFIER_COMMAND)
CreateMenu("&Load Map...", MENU_FILE_LOADMAP, mainFileMenu, KEY_L, MODIFIER_COMMAND)
CreateMenu("", 0, mainFileMenu)
CreateMenu("&Exit", MENU_FILE_EXIT, mainFileMenu, KEY_X, MODIFIER_COMMAND)
UpdateWindowMenu mainWindow
AddHook EmitEventHook, EventHook, Self
End Method
End Type
Global myApp:TApp = New TApp
While True
WaitEvent()
Wend
couldnt figure out what yo wanted at first but is this it. cant think way you version dont work.
EDIT better version IMO
SuperStrict
Const MENU_FILE_NEWMAP% = 1
Const MENU_FILE_SAVEMAP% = 2
Const MENU_FILE_LOADMAP% = 3
Const MENU_FILE_EXIT% = 4
Type TApp
Field mainWindow:TGadget
Field mainFileMenu:TGadget
Field otherWindow:TGadget
Method OnEvent(event:TEvent)
Select event.id
Case EVENT_WINDOWCLOSE
If event.source = mainWindow Then End
If event.source = otherWindow Then HideGadget otherWindow;EnableGadget mainWindow
Case EVENT_MENUACTION
Select event.data
Case MENU_FILE_NEWMAP
ShowGadget otherWindow
DisableGadget mainWindow
Case MENU_FILE_EXIT
End
End Select
End Select
End Method
Function EventHook:Object(id%, data:Object, context:Object)
Local event:TEvent = TEvent(data)
Local app:TApp = TApp(context)
app.OnEvent event
End Function
Method New()
mainWindow = CreateWindow("Wisp Engine Editor", 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()))
MaximizeWindow(mainWindow)
otherWindow = CreateWindow("Register",0,0,320,240,mainWindow ,65)
mainFileMenu = CreateMenu("&File", 0, WindowMenu(mainWindow))
CreateMenu("New &Map...", MENU_FILE_NEWMAP, mainFileMenu, KEY_M, MODIFIER_COMMAND)
CreateMenu("", 0, mainFileMenu)
CreateMenu("&Save Map", MENU_FILE_SAVEMAP, mainFileMenu, KEY_S, MODIFIER_COMMAND)
CreateMenu("&Load Map...", MENU_FILE_LOADMAP, mainFileMenu, KEY_L, MODIFIER_COMMAND)
CreateMenu("", 0, mainFileMenu)
CreateMenu("&Exit", MENU_FILE_EXIT, mainFileMenu, KEY_X, MODIFIER_COMMAND)
UpdateWindowMenu mainWindow
AddHook EmitEventHook, EventHook, Self
End Method
End Type
Global myApp:TApp = New TApp
While True
WaitEvent()
Wend