Selaa lähdekoodia

Added eventqueue examples.

woollybah 6 vuotta sitten
vanhempi
commit
1dab21425f

+ 17 - 0
eventqueue.mod/doc/eventdata.bmx

@@ -0,0 +1,17 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("leftclick/rightclick",0,0,320,240)
+
+Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	Select EventData()
+		Case 1 Print "leftclick"
+		Case 2 Print "rightclick"
+	End Select
+Forever

+ 14 - 0
eventqueue.mod/doc/eventid.bmx

@@ -0,0 +1,14 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local MyWindow:TGadget=CreateWindow("Button Example", 200,200,320,240)
+Local MyButton:TGadget=CreateButton("Click Me",140,60,80,40, MyWindow)
+
+Repeat
+  WaitEvent()
+  Select EventID()
+  Case EVENT_WINDOWCLOSE
+     End
+   End Select
+Forever

+ 19 - 0
eventqueue.mod/doc/eventid_1.bmx

@@ -0,0 +1,19 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("events",0,0,320,240)
+
+Local button:tgadget=CreateButton("Button1",4,4,80,24,window)
+Local canvas:tgadget=CreateCanvas(84,4,80,24,window,1)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	Select EventID()
+		Case EVENT_GADGETACTION Print "gadgetaction (buttonpress, etc.)"
+		Case EVENT_MOUSEMOVE Print "canvas mousemove"
+	End Select
+	
+Forever

+ 23 - 0
eventqueue.mod/doc/eventsource.bmx

@@ -0,0 +1,23 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local MyWindow:TGadget=CreateWindow("Two Buttons Example", 200,200,320,240)
+Local Button1:TGadget=CreateButton("One",140,40,80,40, MyWindow)
+Local Button2:TGadget=CreateButton("Two",140,100,80,40, MyWindow)
+
+Repeat
+  WaitEvent()
+  Select EventID()
+  Case EVENT_WINDOWCLOSE
+     End
+  Case EVENT_GADGETACTION
+    Select EventSource()
+      Case Button1
+         SetGadgetText(Button1,"One clicked")
+      Case Button2
+         SetGadgetText(Button2,"Two clicked")
+      End Select
+   End Select
+Forever
+

+ 19 - 0
eventqueue.mod/doc/eventsource_1.bmx

@@ -0,0 +1,19 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("events",0,0,320,240)
+
+Local button1:tgadget=CreateButton("Button1",4,4,80,24,window)
+Local button2:tgadget=CreateButton("Button2",84,4,80,24,window)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	Select EventSource()
+		Case button1 Print "button1"
+		Case button2 Print "button2"
+	End Select
+	
+Forever

+ 17 - 0
eventqueue.mod/doc/eventtext.bmx

@@ -0,0 +1,17 @@
+'
+' Drop a file onto the window to see EventText() return the path.
+'
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("move mouse",0,0,320,240,Null,15|WINDOW_ACCEPTFILES)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	If EventID()=EVENT_WINDOWACCEPT
+		Print EventText()
+	EndIf
+Forever

+ 17 - 0
eventqueue.mod/doc/eventx.bmx

@@ -0,0 +1,17 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("move mouse",0,0,320,240)
+
+Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	If EventID()=EVENT_MOUSEMOVE
+		Print EventX()
+	EndIf
+Forever
+

+ 16 - 0
eventqueue.mod/doc/eventy.bmx

@@ -0,0 +1,16 @@
+SuperStrict
+
+Import MaxGUI.Drivers
+
+Local window:tgadget=CreateWindow("move mouse",0,0,320,240)
+
+Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)
+
+Repeat
+	WaitEvent()
+	If EventID()=EVENT_WINDOWCLOSE End
+	
+	If EventID()=EVENT_MOUSEMOVE
+		Print EventY()
+	EndIf
+Forever