Input altanativen

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

WEBLink

Betreff: Input altanativen

BeitragMo, Dez 20, 2004 17:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Hy,

mal ne Frage welche altanativen zu Input gibt es denn so? Bei input ist ja der nachteil das dass gesamte Programm angehalten wird.

Theoretisch müsste man ja alle tasten der tastatur abfragen und den entsprechenden Buchstaben dann einsetzen.

Gibt es so was schon als freigegebener Code?
 

noir

BeitragMo, Dez 20, 2004 17:51
Antworten mit Zitat
Benutzer-Profile anzeigen
schau in der OH nach, da findest du so was wie Getkey() Idea

damit bekommst du den ASCII-Code einer gedrückten Taste.

DA

BeitragMo, Dez 20, 2004 17:52
Antworten mit Zitat
Benutzer-Profile anzeigen
Moin,

Arrow https://www.blitzforum.de/viewtopic.php?t=7958

Thx
DarkAngel
Deutscher Blitz Basic Chat

D2006

Administrator

BeitragMo, Dez 20, 2004 17:57
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

user posted image Suchen

Du enttäuschst mich.
Solche alternativen gibt es sogar in unserem Code Archiv.

MfG
D2006
 

Sibitiger

BeitragMo, Dez 20, 2004 19:41
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich stimme D2006 zu:
z.B.
https://www.blitzforum.de/view...highlight=
oder hier 2 möglichkeiten nicht von mir sondern aus suchen und andreen threads:
BlitzBasic: [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

oder:
BlitzBasic: [AUSKLAPPEN]

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


Sibitiger

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group