[Glade-users] number entry

Ah. I missed one aspect I see you desired.
I'm not so sure you can have an Entry send a signal unless the Enter key is pressed (which would be 
I don't see anything like "on_entry1_clicked". Perhaps someone else can advise.

Instead, you might consider having the Entry as planned, and a callback for it, so the user can enter the 
number via the entry, but then also...

Maybe add a little button beside it labelled "Use Keypad" or something, that pops-up the keypad.
Then you're back to using what I had in my previous email.


 From: David Buchan <pdbuchan at yahoo.com>
To: John Thornton <jthornton at gnipsel.com>; Glade Users List <glade-users at lists.ximian.com> 
Sent: Tuesday, November 27, 2012 1:22 PM
Subject: Re: [Glade-users] number entry

Hi John,

I would try to do it by having the number pad being composed of Buttons.
Then I would have a callback for each of the buttons. Each callback would:
?- Take the existing number from the entry (if length is non-zero). That will be a string.
?- Then take print the number associated with the button that was clicked as a character and append it to the 
string in the entry. I use C, so here's some unchecked C code...

I pass the number around in a struct, so I define it here:

typedef struct _ProgData ProgData;
struct _ProgData {
? gint magic_number;
? // You'd probably have other stuff in here.

I assume the entry was grabbed from the glade file using gtkbuilder? We need to get the entry object:

data->entry1 = GTK_WIDGET (gtk_builder_get_object (builder,
 "entry1"));?? // Our number

Same for the buttons, but only if the keypad has popped-up. (I use 10 for 0 because I'm not sure you're 
allowed to name a button as 'button0'.)
data->button10 = GTK_BUTTON (gtk_builder_get_object (builder, "button10"));? // Keypad button 0
data->button1 = GTK_BUTTON (gtk_builder_get_object (builder, "button1"));? // Keypad button 1
data->button2 = GTK_BUTTON (gtk_builder_get_object (builder, "button2"));? // Keypad button 2
data->button9 = GTK_BUTTON (gtk_builder_get_object (builder, "button9"));? // Keypad button 9

Then the callback for the button labelled "3", for example, might be something roughly like:

// Callback to add a digit '3' to the number entry.
on_button3_clicked (GtkButton *button, ProgData *data)
? const gchar *entry1_text;
? char value[256];

? entry1_text = gtk_entry_get_text
 (GTK_ENTRY (entry1));

? memset (value, 0, 256);
? sprintf (value, "%s3", entry1_text);

? data->magic_number = atoi (value);
? gtk_entry_set_text (GTK_ENTRY (data->entry1), value);
? return (TRUE); 

I *think* that should do it, unless I misunderstood.

I wonder if you really need that to be an entry. You can have the buttons update the actual number in the 
variable and show it in a textview instead. Just a thought. I suppose with the text entry, the user can use 
the number pad or type the number in directly. Maybe you desire that extra option.


 From: John Thornton <jthornton at gnipsel.com>
To: Glade Users List <glade-users at lists.ximian.com> 
Sent: Monday, November 26, 2012 12:55 PM
Subject: [Glade-users] number entry
I want to create a number entry glade and have done so. Where I'm having
a problem is to bring that into my main program. What I'm after is when
I click on an entry box the number keypad pops up so I can enter the
numbers and when I press the save button it puts the numbers into the
entry box.

Is this possible? Any examples anywhere?


Glade-users maillist? -? Glade-users at lists.ximian.com

Glade-users maillist? -? Glade-users at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20121127/694c106e/attachment.html>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]