function textinput$ (x as integer,y as integer,w as integer,h as integer,__text as string) dim text as string,keyin as string dim cursor as integer,done as integer text=__text if not (_mousex>x and _mousey>y and _mousex1 then cursor=cursor-1 case 77 ' Right Arrow if cursor<=len(text) then cursor=cursor+1 case 71 ' Home Key cursor=1 case 79 ' End Key cursor=len(text)+1 case 83 ' Delete Key if cursor<=len(text) then text=left$(text,cursor-1)+mid$(text,cursor+1) end if end select elseif len(keyin)=1 then select case asc(keyin) case 22 ' Ctrl + V (Paste) text=left$(text,cursor-1)+_clipboard$+mid$(text,cursor) cursor=cursor+len(pastedata) case 32 to 126 ' Regular Typing text=left$(text,cursor-1)+keyin+mid$(text,cursor) cursor=cursor+1 case 8 ' Backspace if cursor>1 then text=left$(text,cursor-2)+mid$(text,cursor) cursor=cursor-1 end if case 13 ' Enter done=-1 case 27 ' Escape (Cancel) text=__text done=-1 end select end if while _mouseinput:wend if _mousebutton(1) then if (_mousex>x and _mousey>y and _mousexlen(text)+1 then cursor=len(text)+1 else done=-1 end if end if drawtextinput x,y,w,h,text,cursor _limit 60 _display loop until done textinput=text end function sub drawtextinput (x as integer,y as integer,w as integer,h as integer,text as string,state as integer) dim outtext as string dim charwidth as integer:charwidth=8 dim cursorx as integer,textx as integer,texty as integer if state>0 then color backgroundcolor1 else color backgroundcolor2 end if line(x,y)-(x+w,y+h),,bf if state>0 then color highlightcolor else color textcolor end if line(x,y)-(x+w,y+h),,b _printmode _keepbackground outtext=right$(text,min(w/charwidth,len(text))) textx=2+x texty=1+y+h/2-8 _printstring(textx,texty),outtext if state>0 then if int(timer*2) mod 2=0 then dim relativecursor as integer relativecursor=state-(len(text)-len(outtext)) if relativecursor>=1 and relativecursor<=len(outtext)+1 then cursorx=textx+(relativecursor-1)*charwidth line(cursorx,texty)-(cursorx,texty+14),highlightcolor end if end if end if end sub function min(a,b) if a<=b then min=a else min=b end function function clickregion(x as integer,y as integer,w as integer,h as integer) if _mousex>x and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y and _mousexx and _mousey>y-5 and _mousex100 then tmpval=100 slider=tmpval end function function vscrollbar(x as long,y as long,h as long,value as single) dim tmpval as single tmpval=value if buttonhold(x,y,23,23,"U") then tmpval=tmpval-1 if buttonhold(x,h-23,23,23,"D") then tmpval=tmpval+1 tmpval=vbar(x,y+23,h-46,tmpval) if tmpval<0 then tmpval=0 if tmpval>100 then tmpval=100 vscrollbar=tmpval end function function vbar(x as long,y as long,h as long,value as single) dim tmpval as single tmpval=value if _mousex>x and _mousey>y and _mousex100 then tmpval=100 hscrollbar=tmpval end function function hbar(x as long,y as long,w as long,value as single) dim tmpval as single tmpval=value if _mousex>x and _mousey>y and _mousex