I wrote this snippet a while ago, its like a normal windows text box which you click on to select, then type stuff into it. It was written in DBPro.
sync rate 50
sync on
text$ = ""
do
text$ = TextBox(text$,150,100,100,300,20)
sync
loop
Function MouseOverArea(x,y,x2,y2)
if mousex() > x and mousey() > y and mousex() < x2 and mousey() < y2 then over = 1
EndFunction over
function LineBox(left,top,right,bottom)
line left,top,left,bottom
line right,top,right,bottom
line left,top,right,top
line left,bottom,right,bottom
endfunction
Function TextBox(text$,delay,x,y,width,height)
rem Find the ending X and Y co-ordinates ---------------------------------------
x2 = x + width
y2 = y + height
rem Draw text box --------------------------------------------------------------
`Background
ink rgb(0,0,100),0
box x,y,x2,y2
`Outline
ink rgb(255,255,255),0
LineBox(x,y,x2,y2)
rem Draw the text --------------------------------------------------------------
ToDisplay$ = text$ : `Copy the value of the box's text to a temp variable, so the original value
` is not truncated, only the text ot display is.
`Find width of text. If greater than the width of the box, truncate it.
while text width(ToDisplay$) > (width - text width("_"))
ToDisplay$ = left$(ToDisplay$,len(ToDisplay$)-1)
endwhile
`Now draw the text to the screen - highlight text if mouse over
if mouseoverarea(x,y,x2,y2)=1 then ink rgb(255,255,255),0 else ink rgb(200,0,0),0
text x+1,y+1,ToDisplay$
rem If we click on the box, go into editing mode --------------------------------
if MouseOverArea(x,y,x2,y2)=1 and MouseClick()=1
`We've clicked - now go into edit mode
do
rem Draw the text box as usual but with the "_" at the end.
cls
`Background
ink rgb(0,0,100),0
box x,y,x2,y2
`Outline
ink rgb(255,255,255),0
LineBox(x,y,x2,y2)
ToDisplay$ = text$
while text width(ToDisplay$) > (width - text width("_"))
ToDisplay$ = right$(ToDisplay$,len(ToDisplay$)-1)
endwhile
`Now draw the text to the screen - highlight text if mouse over
ink rgb(255,255,255),0
text x+1,y+1,ToDisplay$+"_"
rem Editing ------------------------------------------------------------------
`Add onto the text the value the user is typing. Allow for delay between keystrokes.
If (timer() - LastKeyStroke) > Delay and inkey$()<>""
text$ = text$ + inkey$()
LastKeyStroke = timer()
endif
`Spaces
if spacekey()=1 and (Timer() - LastKeyStroke) > delay then text$ = text$ + " " : LastKeyStroke = timer()
`Backspace
text 10,10,str$(keystate(14))
if KEYSTATE(14) = 1 and (timer() - lastback) > 50 then text$ = left$(ToDisplay$,len(ToDisplay$)-1) : LastBack = timer()
rem Exit from box -------------------------------------------------------------
if mouseclick()=1 and mouseoverarea(x,y,x2,y2)=0 then exit
sync
loop
endif
EndFunction text$
You are the
th person to view this signature.
GRAVITY: I fought the law but the law won