GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Apr 18, 2014 10:36 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Re-setting combo boxes
PostPosted: Sat Oct 13, 2007 4:55 pm 
Offline

Joined: Fri Oct 12, 2007 9:08 am
Posts: 3
I have reasonable experience with GTK, but am very grateful for FAQs and answers that appear in the forums.
I should be pleased if you could help me with a problem I have with combo boxes (text only). Firstly on filling the combo box, at the top of the list the -1th entry is a blank line.I quite like the empty box - signifying no entry. However once any selection has been made from the combo - I can never get back to that state. I want to reset the selections for a new record entry in a DB application and therin lies my problem. If I use set_active to 0 - it shows the 0th entry, if I set it to -1 ; nothing appears to happen. I tried using set_entry_text to "", but of course it objected. My only thought was to make it display " No selection" at the top of the list (the space to make it first in a sorted list, but I feel that there should be an elegant way of doing it, but I cannot find it.
Regards
Charles Upton :


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 13, 2007 5:53 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You cannot add a "" string because it is just a NULL character. The "empty box" is not really a choice per say because the index begins at 0. It is just a silly little thing that happens with an empty combo box. The proper way in terms of UI selection would be to use No Selection or something of the sort that relates to the content of the box. If you _really_ want an empty selection, just add the string that is just a space (" "), but I in no way recommend you using this method since it is poor UI design.

I may be able to help a bit more if you explain why you want an empty selection ...

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 14, 2007 6:55 pm 
Offline

Joined: Fri Oct 12, 2007 9:08 am
Posts: 3
Thanks for your quick response.
The way I am using it is - for each combo on the page shows an empty entry on starting up. If one makes a selection the selection is sitting in the box and an index is returned if the box is queried. Some of the boxes are not being used for a record, so they remain blank. (Note the pop (down) list only appears if one selectes a box). I save that record, and then want to return to a 'clean sheet' for the next record, although 1 or 2 boxes - having been selected may stay with the selection showing as it is highly likely that it would be the same choice for the next record. So as for the starting page, I would like it to show empty boxes for no selection made.
I must admit I didn't like the empty box always showing on a newly created combo box, which has had entries appended, but I have 'built' around that fact.
I have a similar requirement in showing a record if browsing. If a filed was no entry when created then I would like to represent that in the combo box - by blanking it to represent "no selection".
It sounds like I may have completely missed the point with combo boxes.
Regards
Charles


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 2:05 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
could you post a screen shot? I don't completely understand what you're getting at here ...

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: Re-setting combo boxes, with screenshots
PostPosted: Mon Oct 15, 2007 7:47 pm 
Offline

Joined: Fri Oct 12, 2007 9:08 am
Posts: 3
I enclose some snapshots, to try to illustrate what is happening. They are quite small but should be readable.
Snapshot1 Shows a first pass through an Add New record screen, with the period, room and location combos with a selection showing. The others haven't been selected as n/a, so they show they show the empty entry I get when showing the combo boxes the first time. The next snapshot shows a displayed record, where most of the combo boxes are showing a selection, as this is a record where most every field is set.
Snapshot 2 shows the next record, which only has Period, location and room set the other fields are not set, so I gtk_combo_box_set_active (to -1) to try to get back to no selection. If I set it to 0, I get the 0th entry added to the combo.
The last two (I haven't sent) just show all combo boxes as a result of a Clear_Entries() setting the active to -1 has no effect, and setting it to 0 for every box, resets every combo to the first entry.
What I hoped to achieve, was all combos could be reset to an (empty) entry on being 're-set', i.e. as they appear when first shown. But I cannot seem to get back to that condition, once a particular combo box has had a selection made.
Regards
Charles
[img]media:/sda1/Costumes/snapshot1.jpg
[/img]media:/sda1/Costumes/snapshot2.jpg
[img]media:/sda1/Costumes/snapshot3.jpg[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 7:40 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Ok, I think I see what you are trying to do. Basically, combo boxes show no selection by default, but -1 is not a valid selection. The combo box will ignore any value that is less than 0. It is not a good design to allow the user to have a combo box that is unselected. If you want something to be unselected, set the first choice as "No Selection", "None" or something of the sort. Then, when the dialog is displayed, set all of the boxes to the first value.

If the selection is a number, then provide a first choice that is just a space (" "). I know this might be a little bit of a pain, but it will be clearer to the user, and will allow the user to deselect a choice. The user may become confused if you start using the "invalid/unset" and she can't get back to that value.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group