Sample of code im using - I assigned the letters and symbols I wanted to use in a type.
I had checks for cursor and deletion, with a check if shift was held or not.
May not be best way, but it works well for me.
Points of interest KeyHit and KeyDown rest is my code for handling input and edditing.
For lettx.text_letter = Each text_letter
If KeyDown(42) = False And KeyDown(54) = False
If (KeyHit(lettx\scancode) = True And Len(lettx\symbol$) = 1 And StringWidth(curs_count_len$) <= 261)
name2$ = (Left$(name_bar_text$,curs_count))
name1$ = (Mid$ (name_bar_text$,curs_count + 1,(Len(name_bar_text$) - Len(name2$) ) ) )
name_bar_text$ = name2$ + lettx\symbol$ + name1$
curs_count = curs_count + 1
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(14) = True); Backspace
name2$ = (Left$(name_bar_text$,curs_count - 1))
name1$ = (Mid$ (name_bar_text$,curs_count + 1,(Len(name_bar_text$) - (Len(name2$)+1) ) ) )
name_bar_text$ = name2$ + name1$
curs_count = curs_count - 1
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(203) = True)
curs_count = curs_count - 1
If curs_count < 0 Then curs_count = 0
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(205) = True)
curs_count = curs_count + 1
If curs_count > Len(name_bar_text$) Then curs_count = Len(name_bar_text$)
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(199) = True)
curs_count = 0
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(207) = True)
curs_count = Len(name_bar_text$)
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(28) = True) Or (KeyHit(156) = True)
; ********************** code saves **************************
reset = True
ML = 0 : FlushMouse : FlushKeys : Goto codetosave
EndIf
ElseIf KeyDown(42) = True Or KeyDown(54) = True
If (KeyHit(lettx\scancode) = True And Len(lettx\caps_symbol$) = 1 And StringWidth(curs_count_len$) <= 261)
name2$ = (Left$(name_bar_text$,curs_count))
name1$ = (Mid$ (name_bar_text$,curs_count + 1,(Len(name_bar_text$) - Len(name2$) ) ) )
name_bar_text$ = name2$ + lettx\caps_symbol$ + name1$
curs_count = curs_count + 1
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(14) = True); Backspace
name2$ = (Left$(name_bar_text$,curs_count - 1))
name1$ = (Mid$ (name_bar_text$,curs_count + 1,(Len(name_bar_text$) - (Len(name2$)+1) ) ) )
name_bar_text$ = name2$ + name1$
curs_count = curs_count - 1
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(203) = True)
curs_count = 0
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(205) = True)
curs_count = Len(name_bar_text$)
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(199) = True)
curs_count = 0
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(207) = True)
curs_count = Len(name_bar_text$)
curs_count_len$ = (Left$(name_bar_text$,curs_count))
ElseIf (KeyHit(28) = True) Or (KeyHit(156) = True)
; ********************** code saves **************************
reset = True
ML = 0 : FlushMouse : FlushKeys : Goto codetosave
EndIf
EndIf
Next
|