treycerok |
25.11.2011 02:02 |
Помощь с клавиатурой на канве
Вложений: 1
Пишу код клавы для канвы, пришлось создать доп.либу (ибо паскаль с char русского языка не хочет работать), либу прикрепляю.
а вот код:
PHP код:
Program keys; uses rt; var t,tm,nt,el:integer; inp,str,last:string; o,two,fre,fou,fiv,six,sev,eig,nin,zer: array [1..5] of string; begin o[1]:='.'; o[2]:=','; o[3]:='!'; o[4]:='?'; o[5]:='1'; two[1]:='а'; two[2]:='б'; two[3]:='в'; two[4]:='г'; two[5]:='2'; fre[1]:='д'; fre[2]:='е'; fre[3]:='ж'; fre[4]:='з'; fre[5]:='3'; fou[1]:='и'; fou[2]:='й'; fou[3]:='к'; fou[4]:='л'; fou[5]:='4'; fiv[1]:='м'; fiv[2]:='н'; fiv[3]:='о'; fiv[4]:='п'; fiv[5]:='5'; six[1]:='р'; six[2]:='с'; six[3]:='т'; six[4]:='у'; six[5]:='6'; sev[1]:='ф'; sev[2]:='х'; sev[3]:='ц'; sev[4]:='ч'; sev[5]:='7'; eig[1]:='ш'; eig[2]:='щ'; eig[3]:='ъ'; eig[4]:='ы'; eig[5]:='8'; nin[1]:='ь'; nin[2]:='э'; nin[3]:='ю'; nin[4]:='я'; nin[5]:='9'; zer[1]:=' '; zer[2]:='_'; zer[3]:='-'; zer[4]:='"'; zer[5]:='0'; last:=''; el:=1; nt:=0; str:=''; repeat inp:=IntegerToString(GetKeyClicked); setcolor(0,0,0); fillrect(0,0,getWidth,getHeight); setcolor(100,100,200); if inp<>'0' then begin if last='' then begin if inp='48' then str:=str+''+zer[el]; if inp='49' then str:=str+''+o[el] ; if inp='50' then str:=str+''+two[el]; if inp='51' then str:=str+''+fre[el]; if inp='52' then str:=str+''+fou[el]; if inp='53' then str:=str+''+fiv[el]; if inp='54' then str:=str+''+six[el]; if inp='55' then str:=str+''+sev[el]; if inp='56' then str:=str+''+eig[el]; if inp='57' then str:=str+''+nin[el]; last:=inp ; nt:=GetRelativeTimeMs; el:=el+1; end else begin if (nt>(GetRelativeTimeMs-1000*2)) then begin if (last=inp) then begin if last='48' then str:=rrt(str,zer[el]); if last='49' then str:=str+''+o[el] ; if last='50' then str:=rrt(str,two[el]); if last='51' then str:=rrt(str,fre[el]); if last='52' then str:=rrt(str,fou[el]); if last='53' then str:=rrt(str,fiv[el]); if last='54' then str:=rrt(str,six[el]); if last='55' then str:=rrt(str,sev[el]); if last='56' then str:=rrt(str,eig[el]); if last='57' then str:=rrt(str,nin[el]); last:=inp; end else begin el:=1; if last='48' then str:=str+''+zer[el]; if last='49' then str:=str+''+o[el] ; if inp='50' then str:=rrt(str,two[el]); if inp='51' then str:=str+''+fre[el]; if inp='52' then str:=str+''+fou[el]; if inp='53' then str:=str+''+fiv[el]; if inp='54' then str:=str+''+six[el]; if inp='55' then str:=str+''+sev[el]; if inp='56' then str:=str+''+eig[el]; if inp='57' then str:=str+''+nin[el]; last:=inp; end; el:=el+1; end; end; nt:=GetRelativeTimeMs; end; if el=6 then el:=1; if (nt<(GetRelativeTimeMs-1000*2)) then begin last:=''; el:=1; end; drawtext(str,0,0); repaint; until t=2; end.
Проблема состоит в том,что при печатании слова - привет, пишется првет, и так же с нажатием на еденицу.
Функция библиотеки - rrt(String,String one_element)
первый параметр - строка, второй параметр - на какой символ заменит последний символ строки.
CharSet не работает с русскими буквами)так что не надо ругать) буду очень признателен за помощь
|