Your Digital Media Has Never Looked So Good

 
btpoole
Topic Author
Posts: 323
Joined: Fri Feb 15, 2013 2:08 pm

Simple Keyboard

Mon Mar 20, 2017 4:31 pm

I am trying to use keyboarddialog to create a simple keyboard to have user enter an email address. Nothing special. 

function setemail()
?"IN SETEMAIL"
keyboarddialog = createObject("roSGNode", "KeyboardDialog")
keyboarddialog.title= "Enter Email Address"
keyboarddialog.visible = true
keyboarddialog.buttons=["Continue","Cancel"]
m.key=keyboarddialog.keyboard
m.key.showTextEditBox= true
m.top.setFocus(true)
m.top.dialog = keyboarddialog
return m.key.text
end function

Function onKeyEvent(key as String, press as Boolean) as Boolean
      button_val = m.top.dialog.buttonSelected
        if not press then
            if key = "OK"
        if(button_val = 0)
       ?"EMAIL "m.key.text
        m.top.dialog.close = true
        return true
        else if (button_val = 1)
        Print "CANCEL"
       m.top.dialog.close = true
      return true
                      end if
                    end if
                end if
            return FALSE
            end function

My problem lies in the onKey function.  Each time I press OK to accept the character for the email, the onKey fires of course executing the button_val=0 so I never get the complete email put in because of this. Can somebody guide me as to fixing this?
Thanks
 
belltown
Posts: 1441
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: Simple Keyboard

Mon Mar 20, 2017 5:57 pm

Have you tried doing what the documentation recommends?

Typically, you will want to set the KeyboardDialog node title field to prompt the user to enter the string, and add "OK" and "Cancel" buttons by setting the Dialog node buttons field to [ "OK", "Cancel" ], then observe the Dialog node class buttonSelected field to react when the user presses one of those buttons. At any time, the text field can be accessed to obtain the string entered by the user.


i.e. observe the buttonSelected field rather than listening for each individual keypress.
https://github.com/belltown/
 
btpoole
Topic Author
Posts: 323
Joined: Fri Feb 15, 2013 2:08 pm

Re: Simple Keyboard

Tue Mar 21, 2017 3:59 am

belltown, actually no I didn't but I will now. Guess I was think of the old keyboard. Guess it doesn't work exactly the same.  Thanks for pointing me in right direction.

Who is online

Users browsing this forum: No registered users and 5 guests