Re: ANNOUNCE: gtkentrymask - gtkentry with masks and types
- From: Santiago Capel <bluefish ono com>
- Cc: gtk-list gnome org, gtk-app-devel-list gnome org
- Subject: Re: ANNOUNCE: gtkentrymask - gtkentry with masks and types
- Date: Sun, 16 Dec 2001 23:14:40 +0100
Havoc Pennington escribió:
> Santiago Capel <bluefish ono com> writes:
> > Hello, I am proud to announce a new gtk entry widget that allows to add
> > type and mask (with internationalization, I hope ;-) ) to gtkentry. It
> > is at:
> >
> > http://gtkentrymask.sourceforge.net
>
> This looks like a useful widget, it may even work in to the validation
> feature for GtkEntry. See
> http://bugzilla.gnome.org/show_bug.cgi?id=50276. We also need to
> research APIs for this in Java/Swing, Qt, and System.WinForms from the
> .NET platform to see what ideas can be gathered.
Ok, I have read the discussion, and this is my approach:
In relation to focus, I have suffered a great deal with the focus_in and
focus_out events, but not only with GTK but also with Windows (Visual
Basic 5). This is an annoying problem very difficult to solve just with
the events activate, focus_in and focus_out. I think that what we need
is a validate event, that would work in the following way:
- Add to GtkWidget a 'validate' event
gint (* validate_event ) (GtkWidget *widget, GdkEventFocus *event);
- Add to GtkWidget a 'causes_validation' flag/property/bit
- The validate callback function could be like this:
gint my_widget_validate_event_cb(GtkWidget *widget, GdkEventFocus
*event)
{
return my_widget_is_valid();
}
- Behavior.
When my_widget loses its focus, the GTK focus handling routine
should do:
new_focused_widget = find the new focused widget
if new_focused_widget belongs to my dialog/window/form/application
then
if new_focused_widget->causes_validation = true then
emit validate signal on my_widget
if validate returned false then
grab the focus again to my_widget,
assuring that neither the validate nor
focus_in nor focus_out event
are emitted neither on new_focused_widget nor
on my_widget
endif
endif
endif
With this approach, a typical form with the buttons OK and Cancel would
have the Cancel->causes_validation=false
and the rest of widgets (including the OK button) with
causes_validation=true.
Each time a widget loses its focus, the validate event is called on that
widget. If the validation is correct it returns true and the normal
behavior of focus_out is done, it the validation is incorrect, the
validate event (application programmer) can show a message (very
troublesome because of the focus_in and outs caused by the message
window) and return false, in which case, the focus is given back to that
widget. If the user press the Cancel button, there is no validation and
the window closes.
Regards
Santi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]