Eingaberoutine - ersetzt Input // bessere Version von Triton / Wurst / Speck / Triton / / |
Folgende Eingaberoutine ersetzt den Input-befehl: Max. Eingabelänge usw. können kontrolliert werden. Einige Grundfunktionen (Backspace usw.) sind bereits drinne. [code:1:b0c0bc7a82] Graphics 640,480,16,1 SetBuffer BackBuffer() Global antwort$,backtime = MilliSecs(),ccolor While Not KeyDown(1) befehl$ = newinput$(100,100,300,200,">>", 10) If befehl$ = "exit" Then End Text 100,100, befehl$ Flip Cls Wend Function newinput$(x1,y1,x2,y2,frage$,maxl) a = GetKey() If a => 32 And a <= 255 And Len(antwort$) <= maxl-1 Then antwort$ = antwort$ + Chr$(a) If KeyDown(28) Then Return antwort$ If KeyDown(14) Or KeyDown(203) And Len(antwort$) > 0 And MilliSecs()-backtime > 125 Then antwort$ = Left(antwort$,(Len(antwort$)-1)) backtime = MilliSecs() End If Color 25,100,200 Rect x1, y1,x2-x1, y2-y1,1 Color 10,50,150 Rect x1, y1,x2-x1, y2-y1,0 textlange = StringWidth(antwort$) ;Blinkener Cursor texthohe = StringHeight(antwort$) fragelange = StringWidth(frage$) Color 0,50,ccolor Rect x1+28+(Len(antwort$)*8),y1+4,10,texthohe-1,1 ccolor = ccolor + 5 If ccolor = 255 Then ccolor = 100 Color 255,255,255 Text x1+3,y1+3, frage$ + " " + antwort$ End Function [/code:1:b0c0bc7a82] |