Okay then, here is another version which you can only type something if you have focus on the box, you can not type if you dont have focus.
Dim l(0) As String
empty array l()
msg As String
global mx As Integer
global my As Integer
Sync On
Do
cls
mx = mousex() : my = mousey()
inChatBox = mouse_inZoneSquare(0, 350, screen width(), 362)
If inChatBox And mouseclick() = 1 And write = 0 then write = 1
If write = 1
write = 2
Inc writing
If writing > 1 Then writing = 0
endif
If inChatBox = 0 And mouseclick() = 1 then write = 0 : writing = 0
rem get input from user
If writing = 1
msg = txt_InputBox(0, 350)
rem handle array messages after return is pressed
If returnKey() and msg <> ""
sleep 500
array insert at top l()
l() = msg
array index to bottom l()
For t = 0 To array count(l())
v1$ = l()
previous array index l()
next t
clear entry buffer
array index to top l()
endIf
Text 0, 0, "Click anywhere to lose focus on chatbox"
endif
If writing = 0
clear entry buffer
Text 0, 350, "Click here to focus on chatbox"
endif
`Buttons
buttonU = triangle(0, 310, 10, 300, 20, 310)
buttonD = triangle(0, 340, 10, 350, 20, 340)
if buttonU = 1 and mouseclick() = 1 And up = 0 then up = 1
if up = 1
up = 2
next array index l()
if not array index valid(l()) then previous array index l()
endIf
if buttonU = 1 and mouseclick() = 0 then up = 0
if buttonD = 1 and mouseclick() = 1 And down = 0 then down = 1
if down = 1
down = 2
previous array index l()
if not array index valid(l()) then next array index l()
endIf
if buttonD = 1 and mouseclick() = 0 then down = 0
Rem show array text on screen
v = GET ARRAY INDEX(l())
v1 = v
If v1 => 0 and v1 =< array count(l()) Then Text 40, 336-(0*12), l(v1)
v1 = v+1
If v1 => 0 and v1 =< array count(l()) Then Text 40, 336-(1*12), l(v1)
v1 = v+2
If v1 => 0 and v1 =< array count(l()) Then Text 40, 336-(2*12), l(v1)
v1 = v+3
If v1 => 0 and v1 =< array count(l()) Then Text 40, 336-(3*12), l(v1)
rem draw chatbox frame
line 0, 300, screen width(), 300
line 0, 350, screen width(), 350
line 0, 366, screen width(), 366
Sync
Loop
end
Function txt_InputBox(x As Integer, y As Integer)
Local v As String
v = Entry$(1)
Text x, y, "Say: "+v
endFunction v
Function triangle(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, x3 As Integer, y3 As Integer)
v = mouse_inZoneTriangle(x1, y1, x2, y2, x3, y3)
If v then ink Rgb(255, 0, 0), 0
line x1, y1, x2, y2
line x1, y1, x3, y3
line x2, y2, x3, y3
ink Rgb(255, 255, 255), 0
endFunction v
Function mouse_inZoneTriangle(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, x3 As Integer, y3 As Integer)
dABx = x2-x1
dABy = y2-y1
dBCx = x3-x2
dBCy = y3-y2
rem if verts are clockwise
If (dABx*dBCy - dABy*dBCx) < 0
If dABx*(my-y1) >= dABy*(mx-x1) Then ExitFunction 0
If dBCx*(my-y2) >= dBCy*(mx-x2) Then ExitFunction 0
If (x1-x3)*(my-y3) >= (y1-y3)*(mx-x3) Then ExitFunction 0
rem verts are ccw
Else
If dABx*(my-y1) < dABy*(mx-x1) Then ExitFunction 0
If dBCx*(my-y2) < dBCy*(mx-x2) Then ExitFunction 0
If (x1-x3)*(my-y3) < (y1-y3)*(mx-x3) Then ExitFunction 0
EndIf
rem point is inside triangle
EndFunction 1
Function mouse_inZoneSquare(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)
Local i As Boolean
If mx > x1 And mx < x2 And my > y1 And my < y2
i = 1
Else
i = 0
EndIf
EndFunction i
There is always one more imbecile than you counted on.