MaxGui, Multiple canvas objects & Hooks

BlitzMax Forums/BlitzMax Beginners Area/MaxGui, Multiple canvas objects & Hooks

Leo Santos(Posted 2006) [#1]
Hey everybody!

While doing an OOP exercise using multiple canvas objects, I ran into the following problem:

How do I get the event to identify in which canvas the event happened? (a MouseEnter event, for instance).

If you look at the code, you'll see that each Viewport object contains a canvas gadget, and has a "mouseover" field. But regardless of which canvas the mouse entered, the first created viewport always gets the event.

The biggest problem is that I don't want to use something like a timer to redraw all viewports, I only want to redraw the one that gets the event... but only the first Viewport is getting those events!

Maybe the problem is in the EventHook functions, which I re-used from the help and don't quite understand...

Any help is welcome!
Thanks,
Leo.



Thanks for the help with the "codebox" thing, Rik!


RiK(Posted 2006) [#2]
(By the way, how do i post a code in a small textbox? Can I specify the number of lines here?)


You'll be wanting the <CODEBOX></CODEBOX> tag then (use '[' square brackets instead though).

Lots of useful info in the FAQ

and specifically for the forum codes in ..

What are the forum codes?


fredborg(Posted 2006) [#3]
Method OnEvent(event:TEvent)	
  If event
    If event.source = Canvas
      Select event.id
        ...
        ...
      EndSelect
    EndIf
  EndIf
EndMethod



Leo Santos(Posted 2006) [#4]
Hey Fred,

Selecting the Event Id didn't really fix all the problems, but it got me halfway there, and I was able to figure out the rest. (had to change the event hook stuff... at least now I understand it!). Thanks!!!

Now that I got over it, I'm building a map editor that, when in GUI mode, has several viewports with different functions, but when in FullScreen mode, only "plays" the contents of the main viewport (the game itself), which don't use MaxGUI at all. I'll post something I've done with it in the next days...or weeks...

Thanks again!