Event Questions
BlitzPlus Forums/BlitzPlus Beginners Area/Event Questions
| ||
| I'm still practically a fetus to blitz+, and I haven't utilized any of the GUI capabilities such as Gadgets, Events, Windows and Toolbars. I was just curious in how I could use these in a program usefully, Thanks Siopses |
| ||
Global window% = CreateWindow()
Repeat
Events()
Forever
Function Events(wait% = 10)
Select WaitEvent(wait%)
Case $401 ; Gadget has been pressed/modified
Select EventSource()
case button%; Your gadgets (buttons etc)
End Select
Case $803 ; X button has been pressed
Select EventSource()
Case window%
FreeGadget window%
End
Default
FreeGadget ActiveWindow()
End Select
End Select
End Function
|
| ||
| Events in a nutshell: You're only doing things when an event happens. With polling (like in B3d) you're *always* doing things 'n updates, even if nothing new happens. The event way is the way the OS works, so it's a lot better, if you ask me. The B+ events are mainly done for the Windows GUI, but the timer event could also be used for games. Instead of WaitTimer you just use a timer event, and on each timer event you update your game. Basically: once you get the idea of events you never want to go back, in Blitzmax this is all even better as you can make your own events there. |
| ||
| How would I use these events, I know that there useful, but how would I use, for instance a menu. How would I make and use a menu? |
| ||
| A simple window menu? That's all written down in the manual including a perfect example. Really, the B+ manual is quite good, first toy a bit with the manual and its small examples, then after a week try some new code of your own. Unless of course you were referring to non-GUI menus. That's something you'll have to code yourself then.. |
| ||
| Thanks for the help! :) |
| ||
| I've already been using those manual example's, they don't help me much, I just wanted to know how I could use a menu on a window. The example isn't going to assist me there infact, whenever I try to use what it tells me a error screen pops up. |
| ||
| Dunno, I learnt myself B+ without this forum, just with the manual.. was all pretty easy. Anyhoo.. this should work.
window=CreateWindow("window",0,0,640,480)
filemenu=CreateMenu("&File",0,WindowMenu(window))
filemenuopen=CreateMenu("&Open",10,filemenu)
empty=CreateMenu("",999999,filemenu)
filemenusave=CreateMenu("&Save",20,filemenu)
filemenusaveas=CreateMenu("Save &As",30,filemenu)
empty=CreateMenu("",999999,filemenu)
filemenuquit=CreateMenu("&Quit",40,filemenu)
editmenu=CreateMenu("&Edit",1,WindowMenu(window))
toolsmenu=CreateMenu("&Tools",2,WindowMenu(window))
helpmenu=CreateMenu("&Help",3,WindowMenu(window))
UpdateWindowMenu window
Repeat
WaitEvent()
If EventID()=$803 End
If EventID()=$1001
Select EventData()
Case 10 RequestFile("test")
Case 40 End
End Select
DebugLog EventData()
EndIf
Forever
|