Einfaches Input-Modul
Übersicht

![]() |
JustusBetreff: Einfaches Input-Modul |
![]() Antworten mit Zitat ![]() |
---|---|---|
Vielleicht erspart es ja jemandem 5 Minuten Schreibarbeit: Einfaches Input-Modul
Code: [AUSKLAPPEN] '--------------------------------------------------------------- ' BlitzMax Input Module '--------------------------------------------------------------- Import BRL.Retro Import BRL.Max2D Module justus.input Type TInput Field x:Int 'The input's X-Coordinate Field y:Int 'The input's Y-Coordinate Field font:TImageFont 'The font used to display the input Field currentContent:String 'Content that has already been input Field blinktime:Int 'In milliseconds; 500-0: display cursor; 0-(-500) do not display cursor EndType Rem bbdoc: Erstellt ein Eingabefeld returns: Ein TInput - Objekt End Rem Function CreateInput:TInput(x:Int,y:Int,font:TImageFont) Local tempInput:TInput = New TInput tempInput.x = x tempInput.y = y tempInput.font = font Return tempInput EndFunction Rem bbdoc: Aktualisiert ein Eingabefeld returns: Nichts about: Sowohl die Anzeige als auch die grafische Ausgabe wird hiermit geregelt End Rem Function UpdateInput(tempInput:TInput) Local char:Int = GetChar() If char <> Null Then Select char Case KEY_BACKSPACE tempInput.currentContent = Mid(tempInput.currentContent,1,Len(tempInput.currentContent)-1) Default tempInput.currentContent = tempInput.currentContent + Chr(char) EndSelect EndIf SetImageFont tempInput.font DrawText tempInput.currentContent,tempInput.x,tempInput.y If tempInput.blinktime + 500 > MilliSecs() Then DrawText "|",tempInput.x + TextWidth(tempInput.currentContent),tempInput.y EndIf If tempInput.blinktime + 1000 < MilliSecs() Then tempInput.blinktime = MilliSecs() EndFunction Rem bbdoc: Liefert den Inhalt eines Eingabefeldes returns: Den aktuellen Inhalt des Eingabefelds als Zeichenkette End Rem Function GetInputContent:String(tempInput:TInput) Return tempInput.currentContent EndFunction |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group