1. Creating a new selection box.
- Posted by Vinoba Jun 06, 2011
- 1625 views
Win XP SP3. Euphoria version 4.02 or maybe 4.1 (from Eubins). wxEuphoria 0.15
Relevant parts of the code:
sequence combolst1 = { "Group 1" , "Group 2" , "Group 3" , "Group 4" , "Group 5" , "Group 6" } combolst1 = combolst1 & { "Group 7" , "Group 8" , "Group 9" , "Group 10" , "Group 11" , "Group 12" } combolst1 = combolst1 & { "Group 13" , "Group 14" , "Group 15" , "Group 16" , "Group 17" , "Group 18" } combolst1 = combolst1 & { "Group 19" , "Group 20" , "Group 21" , "Group 22" , "Group 23" , "Group 24" } --.... wxFrame, wxpanel, Win created global constant FurboxF1 = create( wxComboBox , {Win, -1, "Furniture", fxpos[3] , 5, wd2 , ht, combolst1 } ) , -- etc etc etc procedure FurboxSelect (atom this, atom event_type, atom id, atom event) --.... index = get_selection( combolst1 ) --.... string = get_string_selection( combolst1 ) if index > 0 then Button2 = create( wxButton, {Win, -1, {string} , xpos[3], ypos[12] , wd2*2, ht} ) end if --.... end procedure set_event_handler(FurboxF1, get_id(FurboxF1), wxEVT_COMMAND_BUTTON_CLICKED, routine_id( "FurboxSelect" ))
Nice screen created with many similar comboboxes. I can open the combobox and see all the items. I want to click on one item, e.g. "Group 8" and then create a ListBox with about 60 items in it, for further clicking to display the characteristics of each item of furniture. I have struggled for about 4 hours, but can't seem to get going.
I have looked at the demos, such as list.exw, display_demo.exw, etc., but no success. The combobox title changes to "Group 8", but no new button appears at the expected location.
I tried to create another combobox or listbox instead of Button2, but nothing happens.
Any help will be gratefully accepted. Thanks in advance.
2. Re: Creating a new selection box.
- Posted by euphoric (admin) Jun 07, 2011
- 1613 views
Try this: create all the listboxes you are expecting you might need and make them invisible. Then, when the user clicks on a listbox, make the hidden listbox visible. Then you can hide it again when it's not needed.
Also, Button2 in your example is never declared.
3. Re: Creating a new selection box.
- Posted by Vinoba Jun 07, 2011
- 1568 views
Try this: create all the listboxes you are expecting you might need and make them invisible. Then, when the user clicks on a listbox, make the hidden listbox visible. Then you can hide it again when it's not needed.
Also, Button2 in your example is never declared.
-- The problem might be a lot simpler - my understanding of set_event_handler(FurboxF1, get_id(FurboxF1), wxEVT_COMMAND_BUTTON_CLICKED, routine_id( "FurboxSelect" )) -- and the subsequent control given to procedure FurboxSelect (atom this, atom event_type, atom id, atom event) -- Surely it is somewhere in there, that I am not able to trap the Item clicked. -- Either wxEuphoria is not doing it or I do not know how to create another -- Window or Box after the click. Or perhaps, I am using the wrong control.
4. Re: Creating a new selection box.
- Posted by ghaberek (admin) Jun 07, 2011
- 1557 views
I think this demo accomplishes what you need. Make sure you're using wxEVT_COMMAND_COMBOBOX_SELECTED to detect when the list selection changes. Then as euphoric said, create the listbox immediately, hide it, then show it again later.
Hope this helps,
-Greg
include "wxeu/wxeud.e" without warning constant frmMain = create( wxFrame, {0, -1, "Combo Demo", -1, -1, 320, 240} ), pnlMain = create( wxPanel, {frmMain} ), lblList1 = create( wxStaticText, {pnlMain, -1, "Furniture:", 10, 14, 60, 16} ), cmbList1 = create( wxComboBox, {pnlMain, -1, "", 80, 10, 120, 20} ), lblList2 = create( wxStaticText, {pnlMain, -1, "Details:", 10, 44, 60, 16} ), lstList2 = create( wxListBox, {pnlMain, -1, 80, 40, 120, 120} ), $ -- populate the combobox for i = 1 to 24 do add_item( cmbList1, sprintf("Group %d", i) ) end for -- hide the details show_window( lblList2, wxFalse ) show_window( lstList2, wxFalse ) procedure combobox_handler( atom this, atom event_type, atom id, atom event ) integer index = get_selection( this ) sequence item = get_combo_item_string( this, index ) -- clear any existing details clear_list( lstList2 ) -- populate the details for i = 1 to 20 do add_item( lstList2, sprintf("%s Item %d", {item, i}) ) end for -- show the details show_window( lblList2, wxTrue ) show_window( lstList2, wxTrue ) end procedure set_event_handler( cmbList1, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("combobox_handler") ) wxMain( frmMain )
5. Re: Creating a new selection box.
- Posted by Vinoba Jun 07, 2011
- 1562 views
Looks good.
I will try and let you know tomorrow.
It is just that I do not want to be coming back to the forum too often with trivial questions.
Thanks.
6. Re: Creating a new selection box.
- Posted by Vinoba Jun 08, 2011
- 1503 views
Greg: I needed two levels of depth of display.
I have modified your program posted above, (which incidentally works perfectly) to get a further level of classification.
There is still some problems with display, particularly after displaying the items and then starting from Main level.
Thanks for your help
-- Program testcombo.exw -- include "wxeu/wxeud.e" without warning sequence listsize = {24 , 60 , 75 } integer mainwd = 500 , mainht = 300 , xposlbl = 10 , yposlbl =14 , lblwd = 60 , lblht= 60 integer xposbox = 80 , yposbox=10 , boxwd = 120 , boxht = 20, goodht = 120 constant frmMain = create( wxFrame, {0, -1, "Combo Demo", -1, -1, mainwd, mainht} ), pnlMain = create( wxPanel, {frmMain} ), lblMain1 = create( wxStaticText, {pnlMain, -1, "Furniture:", xposlbl, yposlbl, lblwd, lblht} ), mainBox = create( wxComboBox, {pnlMain, -1, "Fbox", xposbox, yposbox, boxwd, boxht } ), lblType = create( wxStaticText, {pnlMain, -1, "Type:", xposlbl, yposlbl+60, lblwd, lblht} ), typeBox = create( wxComboBox, {pnlMain, -1,"Ibox", xposbox, yposbox+50, boxwd, goodht} ), lblItems = create( wxStaticText, {pnlMain, -1, "Items:", xposlbl+160+boxwd, yposbox, lblwd, lblht} ), itemList = create( wxListBox, {pnlMain, -1, xposbox+20+boxwd, yposbox+25, boxwd+80, goodht} ), $ -- populate the combobox for i = 1 to listsize[1] do add_item( mainBox, sprintf("Group %d", i) ) end for -- hide the details -- show_window( lblType , wxFalse ) show_window( typeBox , wxFalse ) -- show_window( lblItems , wxFalse ) show_window( itemList, wxFalse ) procedure mainbox_handler( atom this, atom event_type, atom id, atom event ) integer index = get_selection( this ) sequence item = get_combo_item_string( this, index ) -- clear any existing details clear_list( typeBox ) clear_list( itemList ) -- populate the details for i = 1 to listsize[2] do add_item( typeBox , sprintf("%s Type %d", {item, i}) ) end for -- show the details show_window( lblType , wxTrue ) show_window( typeBox , wxTrue ) end procedure set_event_handler( mainBox, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("mainbox_handler") ) procedure typebox_handler( atom this, atom event_type, atom id, atom event ) integer index = get_selection( this ) sequence item = get_combo_item_string( this, index ) -- clear any existing details clear_list( typeBox ) clear_list( itemList ) -- populate the details for i = 1 to listsize[3] do add_item( itemList, sprintf("%s Item %d", {item, i}) ) end for -- show the details show_window( lblItems , wxTrue ) show_window( itemList, wxTrue ) end procedure set_event_handler( typeBox , -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("typebox_handler") ) wxMain( frmMain )
7. Re: Creating a new selection box.
- Posted by ghaberek (admin) Jun 08, 2011
- 1515 views
Aside from the over alignment, I think the primary problem is that your label height (lblht) is 60, which is way too tall for a single line of text. I typically set my labels to 16 pixels high and drop them down by 4 pixels so they line up with the text of other controls.
Once you learn how to use sizers, you'll find things are much easier to arrange on the screen.
-Greg
8. Re: Creating a new selection box.
- Posted by Vinoba Jun 08, 2011
- 1513 views
Aside from the over alignment, I think the primary problem is that your label height (lblht) is 60, which is way too tall for a single line of text. I typically set my labels to 16 pixels high and drop them down by 4 pixels so they line up with the text of other controls.
Once you learn how to use sizers, you'll find things are much easier to arrange on the screen.
-Greg
I changed the label height to 18. The problem is as follows. When I go from mainbox to typebox I can play around between the two. However, when I click into the type box and show the items in the third box, I can go back to type box and change selections but if go straight to mainbox from itemlist, I can't change to something else in the typebox
9. Re: Creating a new selection box.
- Posted by mattlewis (admin) Jun 08, 2011
- 1507 views
Once you learn how to use sizers, you'll find things are much easier to arrange on the screen.
+1
This could use some prettying up / spacing tweaks, but here's a version that uses sizers.
-- Program testcombo.exw -- include "wxeu/wxeud.e" without warning sequence listsize = {24 , 60 , 75 } constant frmMain = create( wxFrame, {0, -1, "Combo Demo", -1, -1, 600, 300} ), pnlMain = create( wxPanel, {frmMain} ), lblMain1 = create( wxStaticText, {pnlMain, -1, "Furniture:"} ), mainBox = create( wxComboBox, {pnlMain, -1, "Fbox"} ), lblType = create( wxStaticText, {pnlMain, -1, "Type:"} ), typeBox = create( wxComboBox, {pnlMain, -1,"Ibox"} ), lblItems = create( wxStaticText, {pnlMain, -1, "Items:"} ), itemList = create( wxListBox, {pnlMain} ), main_sizer = create( wxBoxSizer, wxHORIZONTAL ), left_sizer = create( wxBoxSizer, wxVERTICAL ), right_sizer = create( wxBoxSizer, wxHORIZONTAL ), furniture_sizer = create( wxBoxSizer, wxHORIZONTAL ), type_sizer = create( wxBoxSizer, wxHORIZONTAL ), $ add_window_to_sizer( furniture_sizer, lblMain1, 0, 0, 0 ) add_window_to_sizer( furniture_sizer, mainBox, 0, 0, 0 ) add_window_to_sizer( type_sizer, lblType, 0, 0, 0 ) add_window_to_sizer( type_sizer, typeBox, 0, 0, 0 ) add_window_to_sizer( right_sizer, lblItems, 0, 0, 0 ) add_window_to_sizer( right_sizer, itemList, 1, 0, 0 ) add_sizer_to_sizer( left_sizer, furniture_sizer, 0, 0, 0 ) add_sizer_to_sizer( left_sizer, type_sizer, 0, wxGROW, 0 ) add_sizer_to_sizer( main_sizer, left_sizer, 1, 0, 0 ) add_sizer_to_sizer( main_sizer, right_sizer, 1, 0, 0 ) set_sizer( pnlMain, main_sizer ) procedure resize() layout_sizer( furniture_sizer) layout_sizer( type_sizer ) layout_sizer( left_sizer ) layout_sizer( right_sizer ) layout_sizer( main_sizer ) end procedure -- populate the combobox for i = 1 to listsize[1] do add_item( mainBox, sprintf("Group %d", i) ) end for -- hide the details -- show_window( lblType , wxFalse ) show_window( typeBox , wxFalse ) -- show_window( lblItems , wxFalse ) show_window( itemList, wxFalse ) procedure mainbox_handler( atom this, atom event_type, atom id, atom event ) integer index = get_selection( this ) sequence item = get_combo_item_string( this, index ) -- clear any existing details clear_list( typeBox ) clear_list( itemList ) -- populate the details for i = 1 to listsize[2] do add_item( typeBox , sprintf("%s Type %d", {item, i}) ) end for -- show the details show_window( lblType , wxTrue ) show_window( typeBox , wxTrue ) resize() end procedure set_event_handler( mainBox, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("mainbox_handler") ) procedure typebox_handler( atom this, atom event_type, atom id, atom event ) integer index = get_selection( this ) sequence item = get_combo_item_string( this, index ) -- clear any existing details clear_list( typeBox ) clear_list( itemList ) -- populate the details for i = 1 to listsize[3] do add_item( itemList, sprintf("%s Item %d", {item, i}) ) end for -- show the details show_window( lblItems , wxTrue ) show_window( itemList, wxTrue ) resize() end procedure set_event_handler( typeBox , -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("typebox_handler") ) wxMain( frmMain )
10. Re: Creating a new selection box.
- Posted by Vinoba Jun 08, 2011
- 1468 views
Thanks matt. I will look at it for sure.