Hello
I have a login panel where by user should enter username and password and click login button. But also I want when user press enter from the keyboard, login button should be invoked too.
In toolkit 4 I used the following code and it worked fine, but not in toolkit 5
public Action[] getActions(Object target, Object sender) {
Action[] actions = new Action[1]
;
// Set the action for the requested component
if (sender == btLogin)
{
// Bind the unmodified Enter key to the Ok button.
actions[0]
= new ShortcutAction("Default key",
ShortcutAction.KeyCode.ENTER, null);
}
else
return null;
return actions;
}
public void handleAction(Action action, Object sender, Object target) {
if (target == btLogin)
this.buttonLogin();
}
public void buttonLogin()
{
userN = (String)tfUserName.getValue();
String rawPwd = (String)tfPassword.getValue();
try
{
/**Encrypt a password to get it copared to database encrypted one*/
String pwd = Utilities.encryptFactory(rawPwd);
/**Check if loging information given are correct*/
if(UserControl.authenticateUser(userN, pwd))
{..........
Note: buttonLogin() should be the method to handle login process.
Thanks