MaxGui questions...

BlitzMax Forums/BlitzMax Beginners Area/MaxGui questions...

ninomojo(Posted 2006) [#1]
Hi guys,

Don't MouseX() and MouseY() work in a Canvas using MaxGui? If not, how can I get my mouse X and Y on a canvas?

Thanks,
Nino


bruZard(Posted 2006) [#2]
Local mx:Int
Local my:Int

CreateTimer(60)

Repeat
  WaitEvent()
  Select EventId()
    Case EVENT_MOUSEMOVE
      mx = EventX()
      my = EventY()

    Case EVENT_TIMERTICK
      UpdateCanvas(mx,my)
  End Select
Forever



ninomojo(Posted 2006) [#3]
Thanks.

I wonder why it has to be this complicated. This whole "events" business is giving me headaches.


Dreamora(Posted 2006) [#4]
It isn't complicated.

But either you use event based or you don't.
Mixing isn't a wise decision, as BM itself uses similar event handles to fill the keyboard buffer array for keydown / keyhit as well as the mouse buffer array for mouse down etc.


CS_TBL(Posted 2006) [#5]
Wait a while.. if there's one thing you'll eventually love it's the event-system. Tho I can imagine -a bit- if you come from polling 2d that the event-system looks weird. I had no problems with tho it when going from 3d to blitz+.

And there's actually nothing weird about events, it's just: "when something happens, you'll get a signal to do something with it" That signal is the event. In blitzplus and standard MaxGUI those signals come from the OS (buttonpress etc.), but with MaxGUI you can do your own events, and *that*'s where things get interesting!

I guarantee you: spooky at the start, but a blessing in the end!


ninomojo(Posted 2006) [#6]
I trust you, it's just that I'm too inexperienced for my needs I guess :)

I need some advices on code structure, I'll write a post about that soon. Thanks again guys for sharing the knowledge, this is higly appreciated :)

Nino


SculptureOfSoul(Posted 2006) [#7]
Quick question about events - does the event queue ever get really backed up, and do events ever get lost?

I'm thinking of posting an event within a function that will end up recalling that function until certain conditions are met. I just can't afford to miss the critical begin and end events.


CS_TBL(Posted 2006) [#8]
You mean like recursion using events? Dunno, it sounds somewhat spooky TBH .. :P


Dreamora(Posted 2006) [#9]
And event won't fire a function.
And eventhook that reacts to the events would fire it again, thus no recursion problem there.


CS_TBL(Posted 2006) [#10]
if event.id=EVENT_SOMEEVENT
somefunction
endif

function somefunction()
(..)
event.id=EVENT_SOMEEVENT
emitevent event
end function

just assume this code is ok (don't mind all the code-holes :P) wouldn't it be recursive?


tonyg(Posted 2006) [#11]
... but couldn't you do that with nearly any piece of code?
10 Print "Hello"
20 goto 10



SculptureOfSoul(Posted 2006) [#12]
CS_TBL, that's basically what I'd be doing. Actually, the initial event is not going to be posted by the function called by the event, but by another function.

Sticking with the names you provided, SomeFunction() needs to get called basically every frame for brief periods of time - but does not need to be called at all 95% of the time.

It seemed like posting an event, whose event handler calls the function - and then posting the event from within the function until the function is finished, is the most elegant way to handle the situation. Oh yeah, the other criteria is that the event itself (streaming large files into banks) could take a few seconds if I did it all at once, but instead I just stream a few hundred bytes and then post the event and exit the function so that the rest of my main loop can execute.

Maybe there's a much better way to do this?