January 26, 2021, 11:03:07 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
User Input
»
[bmx] Text input by lonnieh [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bmx] Text input by lonnieh [ 1+ years ago ] (Read 592 times)
BlitzBot
Jr. Member
Posts: 1
[bmx] Text input by lonnieh [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:40 AM »
Title :
Text input
Author :
lonnieh
Posted :
1+ years ago
Description :
Heres a text input type that I've hacked up, with blinking cursor. Just need to call Update once in your loop. EDIT: You may need to set your orientation/alpha either before you call the update method or by adding it into the type itself
Code :
Code: BlitzMax
Graphics
640
,
480
Local
text:GInput = GInput.Create
(
10
,
30
,
":-D "
)
While
Not
KeyHit
(
KEY_ESCAPE
)
Cls
DrawText
"Check it out. Press [ESC] to exit."
,
10
,
10
text.Update
Flip
FlushMem
Wend
Type
GInput
Field
text:
String
, enabled:
Int
=
True
Field
width:
Int
, cursor:
Int
=
False
, x:
Int
, y:
Int
, time:
Long
=
MilliSecs
(
)
Method
Update
(
)
If
enabled
Then
Local
q:
Int
= GetChar
(
)
If
q >
0
Then
Select
q
Case
KEY_BACKSPACE
text =
Left
(
text,
Len
(
text
)
-
1
)
Case
KEY_ENTER
'I don't know what you'd want to do with this, so I
'left it blank, perhaps its time for function pointers.
Case
KEY_TAB
text:+
" "
Default
If
Not
KeyDown
(
KEY_ALT
)
And
Not
KeyDown
(
KEY_CONTROL
)
Then
text:+
Chr
(
q
)
End
Select
width = TextWidth
(
text
)
cursor =
True
time =
MilliSecs
(
)
End
If
If
MilliSecs
(
)
> time +
400
Then
cursor =
Not
cursor
time =
MilliSecs
(
)
End
If
If
cursor
Then
DrawLine x + width, y +
1
, x + width, y + TextHeight
(
"1"
)
-
1
End
If
End
If
DrawText text, x, y
End
Method
Function
Create:GInput
(
x:
Int
, y:
Int
, text:
String
=
""
)
Local
ret:GInput =
New
GInput
ret.text = text
ret.x = x
ret.y = y
ret.width = TextWidth
(
text
)
Return
ret
End
Function
End
Type
Comments :
Sanctus(Posted 1+ years ago)
Thx
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
User Input
»
[bmx] Text input by lonnieh [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal