Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
cpjamloki
Level 7

design and develop CUSTOM KEYBOARD

Hi,
Is there any example of design and develop CUSTOM KEYBOARD. Actually i want to build a custom keyboard for user registration like enter email id and password and check.
May be it can done by roScreen or roImageCancvas, but have not idea how?
If anybody have any idea or sample code for this please share:How to design?How to develop.

Thanks ,
0 Kudos
2 Replies
RokuMarkn
Level 7

Re: design and develop CUSTOM KEYBOARD

It would be pretty straightforward with roScreen. You just draw a keyboard and keep track of the currently selected key. When you receive arrow buttons you move the selection. When you receive OK you append the currently selected key to the string. Here's a very rough example which just implements 3 keys:


function RunKeyboard(screen as Object) as Void
fontreg = CreateObject("roFontRegistry")
m.font = fontreg.GetDefaultFont(24, false, false)
codes = bslUniversalControlEventCodes()
sel = 0
estring = ""
while true
Draw(screen, sel, estring)
msg = Wait(0, screen.GetMessagePort())
if type(msg) = "roUniversalControlEvent" then
button = msg.GetInt()
if button = codes.BUTTON_RIGHT_PRESSED then
if sel < 2 then sel = sel + 1
else if button = codes.BUTTON_LEFT_PRESSED then
if sel > 0 then sel = sel - 1
else if button = codes.BUTTON_SELECT_PRESSED then
k = KeyInfo(sel)
estring = estring + k.key
end if
end if
end while
end function

function Draw(screen as Object, sel as Integer, estring as String) as Void
screen.Clear(&h101010FF)
for index = 0 to 2
k = KeyInfo(index)
if index = sel then color = &h20F0F0FF else color = &h808080FF
screen.DrawRect(k.x, k.y, k.w, k.h, color)
screen.DrawText(k.key, k.x, k.y, &h000000FF, m.font)
end for
screen.DrawText(estring, 100, 60, &hFFFFFFFF, m.font)
screen.SwapBuffers()
end function

function KeyInfo(index as Integer) as Object
keys = [
{ key:"a", x:100, y:100, w:30, h:24 }
{ key:"b", x:134, y:100, w:30, h:24 }
{ key:"c", x:168, y:100, w:30, h:24 }
]
return keys[index]
end function
0 Kudos
cpjamloki
Level 7

Re: design and develop CUSTOM KEYBOARD

thanks.
0 Kudos