Eingaberoutine - ersetzt Input
Übersicht

![]() |
TritonBetreff: Eingaberoutine - ersetzt Input |
![]() Antworten mit Zitat ![]() |
---|---|---|
Folgende Eingaberoutine ersetzt den Input-befehl: Max. Eingabelänge
usw. können kontrolliert werden. Einige Grundfunktionen (Backspace usw.) sind bereits drinne. Code: [AUSKLAPPEN] ;** Eingaberoutine - ersetzt Input
;** 2003 by Triton ;** www.silizium-net.de Graphics 640,480,16,2 SetBuffer BackBuffer() Global antwort$,backtime = MilliSecs(),ccolor While Not KeyDown(1) befehl$ = newinput$(100,100,300,200,">>", 10) If Len(befehl$) > 0 Then Print befehl$ WaitKey End End If 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 |
||
- Zuletzt bearbeitet von Triton am Mi, März 11, 2009 17:17, insgesamt 2-mal bearbeitet
![]() |
Travis |
![]() Antworten mit Zitat ![]() |
---|---|---|
Das gefällt mir ![]() Code: [AUSKLAPPEN] Graphics 1024,768, 16, 1 SetBuffer BackBuffer() Global antwort$, backtime = MilliSecs(),ccolor Global Eingabe Type star Field x, y, layer End Type n = 500 winkel = 180 For i = 1 To n s.star = New star s\x = Rnd (0,1024) s\y = Rnd (0,768) s\layer = Rnd(1,4) Next Repeat Cls Text 0,0, "Press F1 to change Message of the day" Text 0,20, "Current message of the day: " + Befehl$ If KeyHit(59) Then Eingabe = Eingabe Xor 1 If Eingabe = 1 Then befehl$ = newinput$(100,100,300,200,">>", 20) If befehl$ = "exit" Then End Text 100,100, befehl$ EndIf For s.star = Each star s\x = s\x + Cos(winkel) * s\layer s\y = s\y + Sin(winkel) * s\layer If s\x < 0 Then s\x = 1024 If s\x > 1024 Then s\x = 0 If s\y < 0 Then s\y = 768 If s\y > 768 Then s\y = 0 Color s\layer*50, s\layer*50, s\layer*50 Plot s\x, s\y Next Flip Until KeyHit(1) End 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 Eingabe = 0: 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 Was man aber noch verbessern könnte, wäre ein Zeilenumbruch, oder die automatische Größenanpassung des Eingabefeldes. |
||
www.funforge.org
Ich hasse WASD-Steuerung. Man kann alles sagen, man muss es nur vernünftig begründen können. |
![]() |
Mr.Keks |
![]() Antworten mit Zitat ![]() |
---|---|---|
hmm... ich habe hier auch gerade einen simpelinput rumliegen, der auch in einer schleife gut läuft...
Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() Global mh Global gui_selinp Local text1$="blubber?", text2$="harhAR" Repeat Cls If KeyHit(1) Then FlushKeys : End mh = 0 If MouseHit(1) Then mh = 1 text1$ = gui_input$(10,20,text1$,1) text2$ = gui_input$(15,40,text2$,2) Flip Forever Function gui_input$(x,y,txt$,id) Color 255,255,255 Rect x-1,y-1,StringWidth(txt$)+15,StringHeight(txt)+2,0 If mh If RectsOverlap(x,y,StringWidth(txt)+16,StringHeight(txt),MouseX(),MouseY(),1,1) And gui_erra = 0 gui_selinp = id ElseIf gui_selinp = id gui_selinp = -1 EndIf EndIf If id=gui_selinp Then key=GetKey() If key>31 Then txt$=txt$+Chr(key) If KeyHit(82) Then txt$=txt$+"0" If KeyHit(79) Then txt$=txt$+"1" If KeyHit(80) Then txt$=txt$+"2" If KeyHit(81) Then txt$=txt$+"3" If KeyHit(75) Then txt$=txt$+"4" If KeyHit(76) Then txt$=txt$+"5" If KeyHit(77) Then txt$=txt$+"6" If KeyHit(71) Then txt$=txt$+"7" If KeyHit(72) Then txt$=txt$+"8" If KeyHit(73) Then txt$=txt$+"9" If KeyHit(181) Then txt$=Left(txt$,Len(txt$)-1):txt$=txt$+"/" If KeyHit(83) Then txt$=txt$+"," If KeyHit(14) And Len(txt$)>0 Then txt$=Left(txt$,Len(txt$)-1) Rect x+StringWidth(txt$)+4,y+11,5,1 EndIf Text x+3,y,txt$ Return txt$ End Function |
||
MrKeks.net |
![]() |
Shadow of the night |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hmm.. beide sehr nützlich für Games die von Inarie find ich ein bisschen besser da man dort das Feld anklicken kann in das man schreiben will.
MfG Shadow of the Night |
||
User posted image |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group