Titaniun Blur Event - modal-dialog

I have a text field which I've assigned a blur event to check the input text when the user moves to another text field. If the text field for example is a numeric, the code will check for a numeric value and if it isn't, it then shows an alert box letting the user know.
The problem I have is that all of the text fields have a blur event, such when the user moves from text field A to text field B, the blur event fires and if it's empty, shows the dialogue box. The user clicking OK on the dialogue box then also fires the blur event on text field B which has yet to be completed. This causes a second dialogue box to be presented warning the user that text field B hasn't been populated. This is obvious since the user was moving from A to B.
My question after that rambling, is how do I stop any further blur events from firing whilst serving the original blur event?

Not sure you're exact problem... But you have options.
You can e.cancelBubble = true; or e.bubble = false; in the event handler function.
But it sounds also that this may work for you:
if (textField.value.length > 0 && isNaN(textField.value)) textField.blur(); // this way you blur it manually

Related

How to disable text input for a label but still have it as a button

The Text Fields that Say 100 are the ones i'm referring to.
I have Text Fields that I don't want to be editable until a later point so I turned off User Interaction. However, I still want them to function as a button to go to another view. Is there anyway to turn off text input but still keep it as a button?

Selecting all text in a UITextField when an user has VoiceOver enabled

In my App I have several text fields which a user can edit. If the text field already contains text and the user begins to edit the text field, I want to highlight all text, so it's easier for the user to delete the content of the field.
Searching the web I have found the solution to set the text fields delegate to self and use the function didBeginEditing(). In this function I just call textField.selectAll(nil). As long as I don't use VoiceOver on the phone this works well. As soon as you turn VoiceOver on the text in a textField doesn't get highlighted when beginning to edit the text field. The function didBeginEditing though is still called. I checked this with a simple print statement.
Has anyone an idea why this isn't working? Is there maybe another way to highlight all text in a text field?
Thank you for every answer!
The selection of text is lost when the VoiceOver selects the element. You should select the text after the VoiceOver focus on element.
On didBeginEditing you can check if
UIAccessibility.isVoiceOverRunning and then you select the text after one second.
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
self.textField.selectAll(nil)
}
Not the best solution, but it's working. Also, for a person with vision problem I don't think is useful to select all the text, eventually you should inform the user that the text is selected.

Telling when the user has finished entering text in a GtkComboBoxText

I've created a GtkComboBoxText using gtk_combo_box_text_new_with_entry. When I type into it, the "changed" callback is called for every letter.
How can I tell when the user has finished their entry?
I'd be happy to require the user to press 'Enter' at the end, but that doesn't call the callback.
(I'm using GTK+2.)
(Stackoverflow suggested another Q&A which put me on the path to enlightenment. I hadn't seen it while searching before I wrote my Q.)
It boils down to
g_signal_connect(gtk_bin_get_child(GTK_BIN(cb))/*entry*/, "activate", G_CALLBACK(entryActivated), NULL); where cb is the GtkComboBoxText (GtkWidget*). The callback is called when 'Enter' is pressed.
Pressing enter in a GtkComboBoxText that has an entry causes the child GtkEntry to emit the activate signal.
If the GtkComboBoxText contains an entry (via the 'has-entry' property), its contents can be retrieved using gtk_combo_box_text_get_active_text(). The entry itself can be accessed by calling gtk_bin_get_child() on the combo box.
https://developer.gnome.org/gtk2/stable/GtkEntry.html#GtkEntry-activate
The combo box might be considered as part of a form that has its own apply button.
You can also connect to GtkWidget signals. I can't say which event but there is one that is emitted when a widget loses keyboard focus to another widget in the same window. This would allow save on tab out. This is distinct from the window losing focus to another window which is a signal emitted on the GtkWindow. As the widget that has focus in the window does not change when a window loses focus.

Setting Widget Focus in Gtkada

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.

How can I display a dialog canvas in Oracle Forms Builder?

I have built a form in which the user can view multiple rows of data pulled from a table. The user has the option to select a row, then pressing a button to reject the data in that row, (to be marked as rejected in some STATUS field).
I have also designed a rejection confirmation dialog with the ability for the user to enter some comments or reason for rejection.
I have set up the dialog canvas to appear on its own window with the Type proeperty set to Dialog.
When the user selects a row to reject, here is the code that gets executed:
BEGIN
GO_BLOCK('BLK_ALL_RECORDS');
FIRST_RECORD;
IF :FRM_ALL_ROWS.CHK_SELECT = 1 THEN
:FRM_REJECTION.ID := :FRM_ALL_ROWS.ID;
GO_BLOCK('BLK_REJECTION');
SHOW_VIEW('CNV_REJECTION');
EXIT;
ELSE
NEXT_RECORD;
END IF;
END;
And the rejection form has two buttons, one to confirm and one to cancel. Let's just focus on the cancel button for now. Here is the code that is executed once the Cancel button is pressed:
:BLK_ALL_ROWS.CHK_SELECT := 0; /* Forces removal of the check mark */
GO_BLOCK('BLK_ALL_RECORDS');
HIDE_VIEW('CNV_REJECTION');
The only problem is : once the dialog form appears, it hides the parent form, until the form is dismissed. How can display the dialog form ontop of the parent form with both of them visible (in a modal way?)
The navigation between different canvases can be little bit tricky to get to work. Hard to say what is the problem with not having the form in front of me but the first thing I should do is making sure that the 'Raise on entry' canvas property of the 'main' canvas is set to 'Yes'. This should force this canvas to be displayed when you are moving the cursor back to block 'BLK_ALL_RECORDS'.
Another alternative could be to use SHOW_VIEW() in the cancel dialog logic to force the main canvas to be displayed.
I found out what was the problem finally.
The parent Window had a property [Hide On Exit] which is defaulted to Yes and that made the parent form disappear everytime another window is on display. I set it to NO and called the other form. This time both windows are visible, with the modal one always on top.