Die Routine erkennt nicht wann der Button geklickt wurde und wann nicht.
Würde mich sehr freuen wenn ihr mir helfen könntet.
Code: Alles auswählen
Global OldMausButton.b
InitKeyboard()
InitSprite()
InitMouse()
Structure Button
x1.w
y1.w
x2.w
y2.w
inactive.b
text.s
EndStructure
Dim Button.Button(100)
Button(0)\x1 = 10
Button(0)\y1 = 10
Button(0)\x2 = 80
Button(0)\y2 = 19
Button(0)\text = "Neu"
Button(1)\x1 = 110
Button(1)\y1 = 10
Button(1)\x2 = 80
Button(1)\y2 = 19
Button(1)\text = "Laden..."
OpenScreen(1024, 768, 16, "Gothic Editor")
LoadSprite(0, "gfx\Cursor.bmp", 0) ;Sprites laden
TransparentSpriteColor(0 ,255 ,0 ,255)
Procedure.b DrawButton(button.b)
MausButton1.b = MouseButton(1)
If StartDrawing(ScreenOutput()) <> 0
If MausButton1.b And OldMausButton.b = 0
If MouseX() < Button(button.b)\x1 + Button(button.b)\x2 And MouseX() > Button(button.b)\x1 And MouseY() < Button(button.b)\y1 + Button(button.b)\y2 And MouseY() > Button(button.b)\y1
Wert.b = 2 ;geklickt
EndIf
ElseIf MausButton1.b = 0 And OldMausButton.b
If MouseX() < Button(button.b)\x1 + Button(button.b)\x2 And MouseX() > Button(button.b)\x1 And MouseY() < Button(button.b)\y1 + Button(button.b)\y2 And MouseY() > Button(button.b)\y1
Wert.b = 1 ;losgelassen
EndIf
Box(Button(button.b)\x1 - 1, Button(button.b)\y1 - 1, Button(button.b)\x2, Button(button.b)\y2, 16777215)
EndIf
Box(Button(button.b)\x1, Button(button.b)\y1, Button(button.b)\x2, Button(button.b)\y2, 10197915)
Locate(Button(button.b)\x1 + 1, Button(button.b)\y1 + 1)
DrawingMode(1)
If Button(button.b)\inactive = 0
FrontColor(0, 0, 0)
Else
FrontColor(100, 100, 100)
Wert.b = 0
EndIf
DrawText(Button(button.b)\text)
StopDrawing()
OldMausButton.b = MausButton1.b
ProcedureReturn Wert.b
EndIf
EndProcedure
Repeat
FlipBuffers()
ClearScreen(25,25,5) ;Hintergrundfarbe
Bu0$ = Str(DrawButton(0))
Bu1$ = Str(DrawButton(1))
If StartDrawing(ScreenOutput()) <> 0
DrawingMode(1)
FrontColor(155,155,155)
Locate(100, 100)
DrawText("B0 - " + Bu0$)
Locate(100, 120)
DrawText("B1 - " + Bu1$)
StopDrawing()
EndIf
If Bu0$ <> "0" Or Bu1$ <> "0"
Delay(300)
EndIf
ExamineMouse()
ExamineKeyboard()
DisplayTransparentSprite(0, MouseX(), MouseY())
Until KeyboardPushed(#PB_Key_Escape)
End