Hi,
I've just searched most of the MaxGUI forum and couldn't find an answer to my particular problem.
I looked into the maxGUI docs and it mentions that using event hooks is the 'better' way for rendering canvases in the GUI. So I went that route
and everything seemed to be fine until I added a window menu.
a simple File menu with 'open' and 'new' buttons on it, once clicked, freezes the whole app. It seems like the canvas is getting redrawn
when the file menu is rendering over it, but somehow gets stuck in an endless loop?
below is the source that triggers this issue on my windows XP machine:
am I doing something wrong?
I've just searched most of the MaxGUI forum and couldn't find an answer to my particular problem.
I looked into the maxGUI docs and it mentions that using event hooks is the 'better' way for rendering canvases in the GUI. So I went that route
and everything seemed to be fine until I added a window menu.
a simple File menu with 'open' and 'new' buttons on it, once clicked, freezes the whole app. It seems like the canvas is getting redrawn
when the file menu is rendering over it, but somehow gets stuck in an endless loop?
below is the source that triggers this issue on my windows XP machine:
SuperStrict Import maxgui.win32maxguiex Type TEditor Field _window:TGadget Field _canvas:TGadget Global _timer:TTimer Const MENU_NEW:Int = 101 Const MENU_OPEN:Int = 102 Const MENU_CLOSE:Int = 103 Const MENU_EXIT:Int = 104 Method New() Local width:Int = 1024 Local height:Int = 768 _window = CreateWindow("Editor", 20, 20, width, height) _canvas = CreateCanvas(0, 30, width, height, _window) _canvas.SetLayout(1, 1, 1, 1) _InitGui() End Method Function eventhook:Object(id:Int, data:Object, context:Object) Local event:TEvent Local app:TEditor event = TEvent(data) app = TEditor(context) If event.id = EVENT_GADGETPAINT Or event.id = EVENT_TIMERTICK Then app.OnEvent event Return Null End If return event End Function Method OnEvent(event:TEvent) Select event.id Case EVENT_TIMERTICK RedrawGadget(_canvas) Case EVENT_GADGETPAINT If(event.source = _canvas) Then DebugLog "test" SetGraphics CanvasGraphics(_canvas) Cls() DrawRect(100, 100, 300, 300) Flip() End If End Select End Method Function Run() Local ed:TEditor = New TEditor AddHook EmitEventHook, ed.eventhook, ed ed._timer = CreateTimer(60) While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End End Select Wend End Function Method _InitGui() 'main menu Local mainMenu:TGadget = WindowMenu(_window) Local fileMenu:TGadget = CreateMenu("&File", 1, mainMenu) CreateMenu("&Open", MENU_OPEN, fileMenu) CreateMenu("&New", MENU_NEW, fileMenu) UpdateWindowMenu(_window) End Method End Type TEditor.Run()
am I doing something wrong?