RE: How to enter a floating-point number ?
- From: "Tom Liu" <tom liu flextrade com>
- To: "'Tristan Van Berkom'" <vantr touchtunes com>, "'Gan3sh'" <gan3sh wanadoo fr>
- Cc: gtk-app-devel-list gnome org
- Subject: RE: How to enter a floating-point number ?
- Date: Wed, 26 May 2004 16:24:43 -0400
Example 3. Forcing entry to uppercase.
include <ctype.h>
void
insert_text_handler (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer data)
{
int i;
gchar *result = g_new (gchar, length);
for (i = 0; i < length; i++)
result[i] = islower (text[i]) ? toupper (text[i]) : text[i];
g_signal_handlers_block_by_func (GTK_OBJECT (editable),
insert_text_handler, data);
gtk_editable_insert_text (editable, result, length, position);
g_signal_handlers_unblock_by_func (GTK_OBJECT (editable),
insert_text_handler, data);
g_signal_stop_emission_by_name (GTK_OBJECT (editable), "insert_text");
g_free (result);
}
-----Original Message-----
From: gtk-app-devel-list-bounces gnome org [mailto:gtk-app-devel-list-
bounces gnome org] On Behalf Of Tristan Van Berkom
Sent: Wednesday, May 26, 2004 4:16 PM
To: Gan3sh
Cc: gtk-app-devel-list gnome org
Subject: Re: How to enter a floating-point number ?
Gan3sh wrote:
Hi,
I would like to add a widget in my application to be able to enter a
floating-point number and only that.
If I use a GtkEntry, I didn't see in the doc how to restrict the
available characters to only digits (and also . + -).
And if I use a GtkSpinButton, I didn't see how to set the arrows
unvisible.
Is there another widget for entering only a number ?
Hmmm,
I dont think this should be in the gtk+ domain.
Why not just use a GtkEntry and use string conversion utilities
(i.e. isdigit() or some varient) ?
You can preemptivly deny some charachters input by catching
the GdkEventKey's (i.e. "key-press-event" on the GtkWidget object)
in advance and returning TRUE if you dont want that key to be
processed (i.e. if you dont want the GtkEntry's handler to be called).
Cheers,
-Tristan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]