I posted in haste last night, and after more testing this morning I have updated the module. The html5 keypad behavior is the same on both classic and studio.
relevant code
// arrow keys/home/end can't be used because the scan codes overlap with numeric keypad in html5
function EditBoxes_ConvertHtml5Keypad( ebs ref as tEditBoxes )
s$ as string = ""
index as integer = -1
boxid as integer
pos as integer
text$ as string
boxid = GetCurrentEditBox()
if not boxid then exitfunction // 0 means no edit box has focus
for i = 0 to ebs.boxes.length
if boxid = ebs.boxes[i].id
index = i
exit
endif
next i
if -1 = index then exitfunction // this editbox does not belong to this editboxes instance
if GetRawKeyPressed( 36 ) or GetRawKeyPressed( 37 ) or GetRawKeyPressed( 38 ) or GetRawKeyPressed( 39 ) or GetRawKeyPressed( 40 )
ebs.savepos = GetEditBoxCursorPosition( boxid )
endif
if GetRawKeyReleased( 36 ) or GetRawKeyReleased( 37 ) or GetRawKeyReleased( 38 ) or GetRawKeyReleased( 39 ) or GetRawKeyReleased( 40 )
SetEditBoxCursorPosition( boxid, ebs.savepos )
endif
if GetRawKeyReleased( 110 )
s$ = GetCharBuffer()
if len( s$ )
if CompareString( ".", right( s$, 1 )) then exitfunction
endif
s$ = "."
elseif GetRawKeyReleased( 45 )
s$ = "0"
elseif GetRawKeyReleased( 187 )
s$ = "1"
pos = GetEditBoxCursorPosition( boxid )
text$ = GetEditBoxText( boxid )
if pos > 0
if CompareString( "=", mid( text$, pos, 1 ))
text$ = left( text$, pos-1 ) + right( text$, len(text$)-pos ) // remove =
SetEditBoxText( boxid, text$ )
SetEditBoxCursorPosition( boxid, pos-1 )
endif
endif
elseif 187 = GetRawLastKey()
pos = GetEditBoxCursorPosition( boxid )
text$ = GetEditBoxText( boxid )
if pos > 0
if CompareString( "=", mid( text$, pos, 1 ))
text$ = left( text$, pos-1 ) + right( text$, len(text$)-pos ) // remove = when key held down
SetEditBoxText( boxid, text$ )
SetEditBoxCursorPosition( boxid, pos-1 )
endif
endif
elseif GetRawKeyReleased( 40 )
s$ = "2"
SetEditBoxCursorPosition( boxid, ebs.savepos )
elseif GetRawKeyReleased( 34 )
s$ = "3"
elseif GetRawKeyReleased( 37 )
s$ = "4"
elseif GetRawKeyReleased( 12 )
s$ = "5"
elseif GetRawKeyReleased( 39 )
s$ = "6"
elseif GetRawKeyReleased( 36 )
s$ = "7"
elseif GetRawKeyReleased( 38 )
s$ = "8"
elseif GetRawKeyReleased( 33 )
s$ = "9"
endif
if not len(s$) then exitfunction
pos = GetEditBoxCursorPosition( boxid )
text$ = GetEditBoxText( boxid )
text$ = left( text$, pos ) + s$ + right( text$, len(text$)-pos )
SetEditBoxText( boxid, text$ )
SetEditBoxCursorPosition( boxid, pos+1 )
ebs.savepos = pos+1
endfunction
Definitely not a perfect solution. You can use the mouse to position the editbox cursor but if you type numbers too fast, sometimes the cursor gets out of position. I found the cursor stays in place better when translating the keycode on GetRawKeyReleased() than on GetRawKeyPressed()