Re: Text Fields
- From: Thomas Mailund Jensen <mailund daimi au dk>
- To: gtk-list redhat com
- Cc: gtk-app-devel-list redhat com
- Subject: Re: Text Fields
- Date: 14 Jan 1999 12:08:08 +0100
>>>>> "R" == Ryan Wahle <wahle@ryu.innercite.com> writes:
R> I was wondering if there was a way to get the contents of a text
R> field, when all you use is GtkWidget *text for about 5 text
R> fields.
R> Or should I just use:
R> GtkWidget *text1;
R> GtkWidget *text2;
R> GtkWidget *text3;
R> and so on...
As I understand your question you want to do something like
--<code>-----------------------------------------------------
GtkWidget *text;
text = gtk_text_new (NULL,NULL);
/* stuff */
text = gtk_text_new (NULL,NULL);
/* stuff */
text = gtk_text_new (NULL,NULL);
/* stuff */
/* and here you want to extract text from all the text fields */
--</code>----------------------------------------------------
instead of
--<code>-----------------------------------------------------
GtkWidget *text1;
GtkWidget *text2;
GtkWidget *text3;
text1 = gtk_text_new (NULL,NULL);
/* stuff */
text2 = gtk_text_new (NULL,NULL);
/* stuff */
text3 = gtk_text_new (NULL,NULL);
/* stuff */
/* here you extract the text from text1, text2, and text3. */
--</code>----------------------------------------------------
Is that a correct interpretation of your question?
In that case I suppose you could use gtk_object_set_data to store a
reference to your text widgets, in a container widget. That would be
something like
--<code>-----------------------------------------------------
GtkWidget *window, *text;
text = gtk_text_new (NULL,NULL);
gtk_object_set_data (GTK_OBJECT (window), "text1", text);
/* stuff */
text = gtk_text_new (NULL,NULL);
gtk_object_set_data (GTK_OBJECT (window), "text2", text);
/* stuff */
text = gtk_text_new (NULL,NULL);
gtk_object_set_data (GTK_OBJECT (window), "text3", text);
/* stuff */
/* here you can get to your text widgets with
text = gtk_object_get_data (GTK_OBJECT (window), "text[123]");
*/
--</code>----------------------------------------------------
It is perhaps not as usefull in this example where everything is in
the same function, but if you want to get to the text from other
functions you just need to save a pointer to window in stead of
keeping track of all the text[123] pointers.
/mailund
--
If you STAY in China, I'll give you 4,000 BUSHELS of "ATOMIC MOUSE"
pencil sharpeners!!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]