I'm trying to create a simple test program in Gtkada to bring up a Dialog box upon leaving a specific textbox. I have managed this part, but am having problems resetting the focus back to the original textbox when the Dialog's 'Ok' button is pressed.
The general idea is that the user enters something into a textbox and when they click/tab out of the box (focus out event), some simple Alphanumeric validation is done. If the validation fails, the user is warned with a Dialog, and focus is returned to the textbox they entered erroneous data into.
All I am after is a simple example of how to set the focus back to a textbox when you close the Dialog box which clicking out of the textbox originally called. In Gtkada... I'm using version 2.2 of Gtkada. I can't change the version of Gtkada, or use a different program or language!
Much obliged!
Tim
The most elegant solution, GUI-wise, is to do the validation on a leave_event on each input field, and if that fails display an error message (in red or some such) next to the field. But do not display a dialog or force the focus to a specific field, that would interfere with what the user is trying to do (imagine: I enter an incorrect email address, press tab, get the dialog which I do not read (like most users), start typing my name for the next field, but since the focus went back to the email address, I have no overridden that one and lost my previous input).
If you still want to grab the focus, Gtk.Widget.Grab_Focus is the procedure you want.
Related
I have a Gtk Entry that uses a Entry Completion object. I have set it up to an extent. If I enter the minimum key length number of characters the completion popup shows me available choices. So far so good.
Now what I want is that the text field should show the completion popup even it is empty, as soon as it has focus. Even if set the completion object's minimum key length to 0, the completion popup will not immediately appear as soon as the text field has focus. It will, however, appear if I enter something then delete it, leaving the text field empty.
My real goal is to select an item from a predefined list of choices, quickly, using the keyboard. What I did was to use a Gtk Entry attached to an Entry Completion Object which uses a List Store. Any alternatives are most welcome...
I am using gtkmm/Glade for doing my work. Please tell me if I need to add anything.
Thanks
If you just want to select from a list of predefined choices you'd probably be better using a combo box instead of a entry.
I have this task as a homework for interview - to test the webpage of popular site. Got a pop up form with some text in the fields. The task is to check is there are fields has been changed.
The page constructed that way, doesent matter if the data changed, popup window just closed with no additional text about it. I have no idea how to deal with it. Is there any commands in selenium checking, if the form has been sent?
add1
This is a PopUp changing profile window. It is shown below with my translations as the red font.
It is obvious, when this window opens, some values are already in the textfields (that is ur name/surname that u've entered before).
When u press the save button, this page checks if the data been changed since this window been opened (did u really changed anything).
The html code of "save" button has been shown on the pic2. U can see javaScript listener on the save button. There are somewhere must be a JS code, that checks if the data been changed and sends the form, and canceling the form sending, if there's no changing.
My Goal is to check using selenium, if the form has been sent.
I want to know if there is any way to navigate Dialog components by pressing the Enter Key in the same manner natively implemented by the TAB key?
Though I haven't tried it by handling the keyDown and keyUp events certainly it seems doable. Though you may not be able to intercept the browser produced dialog boxes this way and other dialogs created using Window.alert(). How are you creating the dialogs ?
The tab key is the browser doing the work of changing focus - nothing special needs to be added, you'll find that tab works on any form on the internet (except where explicitly disabled for some reason...).
To move focus with the enter key, you must listen for the onkeydown event (focus change via tab also occurs onkeydown, so selecting this for consistency), check if it was the enter key, and if so, move focus to the next element in the list.
Typical tab focus behavior involves the browser checking the tabIndex of the elements on the page, and finding the next element on the page with a higher tabIndex, or the nearest subsequent sibling/cousin element. I don't have a method to implement this easily, so instead I'm going to focus on just going to the next widget.
GXT 3's FormPanelHelper has some handy methods to look for all Fields - this code could be used as a basis for non-GXT fields as well. Track all FocusEvent and BlurEvent from the fields found in the dialog, and use that to always track the currently focused field. Add a key handler to the dialog itself, to capture all key events, and check if one is the enter key. If so, figure out what the next field is from the currently focused field, and invoke .focus() on it - this will trigger the focus handler described above, so your bookkeeping will be updated correctly.
And as #eliran-m noted, consider leaving the tab key alone - don't get in the way of users navigating the way they are used to. Adding new functionality might be a good thing, but taking away expected behavior probably isn't.
I need to focus a text input into the Facebook login popup. I am using a virtual keyboard to simulate a physical one, but when I click a key, the text input lose focus and the letter is not written into the field.
How could I maintain the focus in the text input?
I'm not sure if creating your own virtual keyboard is a smart idea since all mobiles already have one in there, you just need to set useSoftKeyboard in Flex.
Also, you can always remove focusability to your components by setting focusEnabled and hasFocusableChildren to false.
I finally came to another solution... Using getElementsByTagName('theElementID'), I could get a reference to the textInputs in the browser, and I could modify its attributes...
For example,
emailStringObject =this.html.htmlLoader.window.document.getElementById('email');
emailStringObject.value="example#correo.com"
I am building a little registration page that is going to be accessed via an iPad at a sales office as a kiosk. When I first received the page from the web design company I noticed that the way they set it up was the labels of the input fields appear inside the field (like a watermark). The watermark is cleared out once you focus on the field and then restored if there is no value when you blur off the field.
I noticed that they had a couple password fields in the page that was showing the words PASSWORD and RETYPE PASSWORD in them. I don't want people's password exposed in the Sales Office, however changing the fields to type password means that the watermark labels become masked.
Since they were using jQuery to do the watermark in the input fields, I found another jQuery solution that would swap out the TEXT input field for a PASSWORD input field on focus. When I tested it on my PC in Safari it worked like a charm. However when I was testing the page with my iPhone I noticed that the jQuery field swap on focus only works if I click on the field with my finger. If I am using the on screen keyboard and clicking NEXT to get the field, then the field doesn't get swapped and the on screen keyboard goes away. I have to physically click the field to get the swap to fire. Is there some other even that I can use to trigger the swap instead of focus?
$('#txtRetypePassword-clear').focus(function() {
$('#txtRetypePassword-clear').hide();
$('#txtRetypePassword-password').show();
$('#txtRetypePassword-password').focus();
});
Of course as soon as I posted, I did a little more reading on DiveIntoHTML5.ep.io and saw that HTML5 supports "placeholders" so I thought to myself, I wonder if you can put a placeholder on a PASSWORD input field. YOU CAN!
So I get to rip out all that jQuery because HTML5 supports everything the page was trying to do!