Hi there,
I am currently creating a login screen with Qooxdoo, and now I want to add a
little usability to it.
I have a TextField userField, a PasswordField passwordField (yes, very creative,
I know) and a form.Button okButton. The okButton is initially disabled.
The okButton has an execute event for confirming the login data and loading the
rest of the UI, this is currently working as it should.
Now I have got two problems:
1.)
I want to disable the okButton when there is no text in one of the text fields
and I want to enable the okButton again if there is text in both textfields. I
have tried to achieve this by adding an inline EventListener to both of the text
fields, which checks the value of both text fields and sets the okButton
accordingly.
Here is the code snippet for the userField EventListener, the other one is
almost identical.
userField.addEventListener(
"keyup",
function(keyEvent) {
if (userField.getValue() == "" || passwordField.getValue() ==
"") {
okButton.setEnabled(false);
} else {
okButton.setEnabled(true);
}
if (keyEvent.getKeyIdentifier() == "Enter") {
//alert("Enter pressed!");
passwordField.focus();
}
},
this);
I'm coming to that if-clause with the "Enter" in my next question...
Now here's what happens when trying to use this in my browser (Firefox):
First, I enter some text in the userField text field. The okButton stays
disabled. Good. Now I click on the passwordField or hit the Enter key to switch
there. The okButton is still disabled as intended.
I now start typing text in the passwordField. Now the okButton should become
enabled but is stays disabled. In fact, it stays disabled until I "unfocus" the
current text field and focus back to it.
It soon came to my mind that the problem here is that the value of the text
field only gets changed during the unfocus of the text field. Therefore, as a
workaround, I had the idea to perform this unfocusing and focusing right before
the if clause automatically, and this basically works, but this way I'm not able
to mark the text in the text field (for instance, to delete all the text in the
field).
Is there a way to read the current text within the text field or to find out if
there is any text entered without unfocusing the field?
2.)
The above code snippet also contains an if clause which checks if the Enter key
has been pressed. I use this for switching from the user field to the password
field in a convenient way. Now I want to be able to call the execute event of
the okButton when someone hits the Enter key within the password field. I
understand that there is a method dispatchEvent(Event vEvent, Boolean
vEnableDispose) to achieve this, but how can I use it to call the execute event
of the okbutton?
I tried to call it with
okbutton.dispatchEvent("execute");
but that won't work.
Thanks for any help. :)
Regards,
Daniel Haferkorn
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel