! keyboardFn_02 ! 07/05/2018 22:42:38 Gosub FN gr.open 255, 255, 255, 255, 0, 1 gr.screen sw, sh gr.color 255,100,100,100,1 gr.text.size 0.02*sh gr.text.align 3 gr.text.draw txt, 0.5*sw, 0.45*sh, "Введите текст" dim Txt[2] gr.color 255,0,100,0,1 gr.text.size 0.02*sh gr.text.align 2 gr.text.draw txt[1], 0.5*sw, 0.5*sh, "Вводимый текст" gr.color 255,100,0,0,1 gr.text.size 0.02*sh gr.text.align 2 gr.text.draw txt[2], 0.5*sw, 0.55*sh, "Введенный текст" lt=sw*0 tp=sh*0.47 rt=sw*1 bt=sh*0.57 areashow_01(lt, tp, rt, bt, 2, 1) gr.render activate=1 objText=txt[1] Do ! Клавиатура отдельным модулем ! если activate<>0 значит фокус обработчика событий находится в модуле data=keyboardFN_02(data, activate, objText, 30, "text") bundle.get data, "text", text$ gr.modify txt[2], "text", text$ activate=0 key$=areatouch_01$(lt, tp, rt, bt, 2, 1) if key$="11" then activate=1 gr.render Until 0 end "Конец" FN: fn.def keyboardFN_02(data, activate, textobject, maxLen, type$) ! type$= "text"; "password"; "number"; ! Использование ! ! gr.open ! gr.text.draw obtxt, x, y, text$ ! activate 1 ! Do ! data=keyboardFN_02(data, activate, obtxt, 20, "text") ! activate 0 ! bundle.get data, "text", value$ - возвращаемая переменная текста введенного с клавиатуры ! Until 0 ! IF !data THEN gr.screen sw, sh lt=0 tp=sh*0 rt=sw bt=sh*0.3 w=rt-lt h=bt-tp bundle.create data list.create s, lstTextRu list.add lstTextRu, "ё,1,2,3,4,5,6,7,8,9,0" list.add lstTextRu, "й,ц,у,к,е,н,г,ш,щ,з,х,ъ" list.add lstTextRu, "ф,ы,в,а,п,р,о,л,д,ж,э" list.add lstTextRu, chr$(8679)+",я,ч,с,м,и,т,ь,б,ю,"+chr$(9003) list.add lstTextRu, "?123,En,!,?, ,⎵, ,.,zap,⏎" list.create s, lstTextEn list.add lstTextEn, "1,2,3,4,5,6,7,8,9,0" list.add lstTextEn, "q,w,e,r,t,y,u,i,o,p" list.add lstTextEn, "a,s,d,f,g,h,j,k,l" list.add lstTextEn, chr$(8679)+",z,x,c,v,b,n,m,"+chr$(9003) list.add lstTextEn, "?123,Ru,!,?, ,⎵, ,.,zap,⏎" list.create s, lstSymb list.add lstSymb, "~,1,2,3,4,5,6,7,8,9,0,_" list.add lstSymb, "+,-,*,/,=,$,:,(,),[,],"+chr$(34) list.add lstSymb, chr$(92)+",;,%,^,#,&,|,<,>,{,},'" list.add lstSymb, "§,№,¶,«,»,°,©,®,…,"+chr$(9003) list.add lstSymb, "Abc,., ,⎵, ,@,⏎" list.create s, lstNumb list.add lstNumb, "1,2,3,-" list.add lstNumb, "4,5,6,." list.add lstNumb, "7,8,9,"+chr$(9003) list.add lstNumb, ",0,,⏎" bundle.put data, "lst_table_1", lstTextRu % ⇧ bundle.put data, "lst_table_2", lstTextRu % ⇮ bundle.put data, "lst_table_3", lstTextRu % ⇯ bundle.put data, "lst_table_4", lstTextEn % ⇧ bundle.put data, "lst_table_5", lstTextEn % ⇮ bundle.put data, "lst_table_6", lstTextEn % ⇯ bundle.put data, "lst_table_7", lstSymb bundle.put data, "lst_table_8", lstNumb dim bmp[8] FOR index=1 to 8 bundle.get data, "lst_table_"+int$(index), lst_table list.size lst_table, rows bundle.put data, "table_"+int$(index)+"_code_00", "" bundle.put data, "table_"+int$(index)+"_rows", rows for i=1 to rows list.get lst_table, i, row$ split a$[], row$,"," array.length qcells, a$[] bundle.put data, "table_"+int$(index)+"_row_"+int$(i)+"_cells", qcells for j=1 to qcells if index=2 | index=5 then if a$[j]=chr$(8679) then a$[j]="⇮" bundle.put data, "table_"+int$(index)+"_code_"+int$(i)+int$(j), upper$(a$[j]) elseif index=3 | index=6 if a$[j]=chr$(8679) then a$[j]="⇯" bundle.put data, "table_"+int$(index)+"_code_"+int$(i)+int$(j), upper$(a$[j]) else bundle.put data, "table_"+int$(index)+"_code_"+int$(i)+int$(j), a$[j] endif next next Gr.bitmap.create bmp[index], w, h Gr.bitmap.drawinto.start bmp[index] gr.color 255, 0,200,0,0 gr.set.stroke 2 gr.rect re, lt, tp, rt, bt Hrow=h/rows txsize=Hrow/2 valign=0.3555*txsize for j=1 to rows list.get lst_table, j, row$ split a$[], row$, "," array.length qcells, a$[] Wcell=w/qcells let ctp=tp+(j-1)*hrow let cbt=ctp+hrow let y=(ctp+cbt)/2 for i=1 to qcells if a$[i]="zap" then a$[i]="," let clt=lt+(i-1)*Wcell let crt=clt+Wcell let x=(clt+crt)/2 gr.color 255, 0,200,0,0 gr.set.stroke 2 ! gr.rect re, clt, ctp, crt, cbt gr.color 200, 230,240,230,1 gr.rect re, clt, ctp, crt, cbt gr.color 255, 0,150,0,1 gr.text.align 2 gr.text.size txsize if a$[i]=chr$(9003) then gr.color 255, 150,0,150,1 endif if a$[i]="Ru" | a$[i]="En" | a$[i]="Abc" gr.text.size txsize*0.8 gr.color 255, 150,0,150,1 endif if a$[i]="?123" then gr.text.size txsize*0.7 gr.color 255, 150,0,150,1 endif if a$[i]=chr$(8679) | a$[i]="⏎" then gr.text.size txsize*1.2 gr.color 255, 150,0,150,0 gr.set.stroke sh*0.0015 endif if (index=2 | index=5 ) & a$[i]<>"En" & a$[i]<>"Ru" if a$[i]=chr$(8679) then a$[i]="⇮" gr.text.draw txo, x, y+valign, upper$(a$[i]) elseif(index=3 | index=6 ) & a$[i]<>"En" & a$[i]<>"Ru" if a$[i]=chr$(8679) then a$[i]="⇯" gr.text.draw txo, x, y+valign, upper$(a$[i]) else gr.text.draw txo, x, y+valign, a$[i] endif next next Gr.bitmap.drawinto.end gr.bitmap.draw sp, bmp[index], 0, 0.7*sh gr.hide sp bundle.put data, "skin_"+int$(index), sp gr.color 255, 0, 100, 0, 1 gr.text.size sh*0.1 gr.text.align 2 gr.text.draw txt,0,0,"" bundle.put data, "simb", txt NEXT ENDIF IF activate THEN skin=1 if type$="number" then skin=8 gr.get.value textobject, "text", key$ text$=key$ if type$="password" then text$="" key$="" endif gr.modify textobject, "text", text$+"|" gr.render gr.screen sw, sh lt=0 tp=sh*0.7 rt=sw bt=sh w=rt-lt h=bt-tp dim skin[8] for i=1 to 8 bundle.get data, "skin_"+int$(i), skin[i] gr.modify skin[i], "y", tp gr.hide skin[i] next bundle.get data, "simb", symb gr.show skin[skin] for i=sh*1.2 to sh*0.7 step -sh*0.05 gr.modify skin[skin], "y", i gr.render next gr.modify skin[skin], "y", tp gr.render array.load vib[],0,50 vrem_0=int(time()/100) Do let vrem=int(time()/100-vrem_0) if !mod(vrem, 8) gr.modify textobject, "text", text$+" " elseif !mod(vrem, 4) gr.modify textobject, "text", text$+"|" endif gr.render gr.touch fl, xtch, ytch IF fl & ytch>tp & ytchlt & xtchttp & ytchtlt & xtch=maxLen if !mess then popup "Максимальное количество символов "+int$(maxLen) mess=1 endif elseif k$="⎵" key$=key$+" " if skin=2 | skin=5 then gr.hide skin[skin] skin=skin-1 gr.show skin[skin] endif elseif upper$(k$)="ZAP" key$=key$+"," else key$=key$+k$ if skin=2 | skin=5 then gr.hide skin[skin] skin=skin-1 gr.show skin[skin] endif endif % K$ ELSEIF type$="number" THEN if k$="." then if !tchk then if key$="" then key$="0." elseif key$="-" key$="-0." else key$=key$+"." endif tchk=1 else if right$(key$, 1)="." then key$=left$(key$, len(key$)-1) tchk=0 endif endif elseif k$="-" if !minus then key$="-"+key$ minus=1 else key$=right$(key$, len(key$)-1) minus=0 endif elseif k$="⌫" if right$(key$, 1)="." then tchk=0 if key$="-" then minus=0 endif key$=left$(key$, len(key$)-1) elseif k$="0" if key$="" then key$="0." tchk=1 elseif key$="-" key$="-0." tchk=1 elseif key$="0" key$="0.0" tchk=1 elseif key$="-0" key$="-0.0" tchk=1 else key$=key$+"0" endif elseif k$="⏎" ENTER=1 else key$=key$+k$ endif ENDIF % TYPE if type$="password" then text$="" for i=1 to len(key$) text$=text$+"●" next gr.modify textobject, "text", text$+"|" else text$=key$ gr.modify textobject, "text", text$+"|" endif ! ПОКАЗ СИМВОЛА bundle.get data, "simb", symb if k$="⏎" then elseif k$="⌫" xtch=xtch-sw*0.04 symb$=k$ elseif k$="⎵" | k$=" " ytch=ytch-sh*0.08 symb$="⎵" elseif k$="zap" symb$="," else symb$=k$ endif if xtch>sw*0.9 then xtch=xtch-sw*0.05 elseif xtch=maxLen elseif k$=" " | k$="⎵" key$=key$+" " else ! key$=key$+k$ endif if type$="password" then text$="" for i=1 to len(key$) text$=text$+"●" next gr.modify textobject, "text", text$+"|" gr.render else text$=key$ gr.modify textobject, "text", text$+"|" gr.render endif endif Until !fl ! bool=0 gr.modify symb, "text", "" ELSEIF ytchtp & ytchlt & xtchtp & ytchlt & xtchttp & ytchtlt & xtchlt & xtchtp & ytchclt & xtchctp & ytchclt & xtchctp & ytch