ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
itemcurrent in ComboBox
The itemcurrent node does not seem to be updating when the ComboBox changes value.
I've tried calling refreshview() on the combobox node, but that's not helping. What's the right way to do this? Neil |
#2
|
||||
|
||||
The combobox updates its itemcurrent when you select something in the combobox, but it doesn't update its visuals when you just change the itemcurrent.
If you want to update the combobox after explicitly changing its itemcurrent value, call comborefresh(). refreshview() will destroy the combobox and recreate it. When it recreates it this way, it doesn't use the itemcurrent value to set the originally selected item. If you are dynamically changing the list of items, you will need to call refreshview() then comborefresh(). |
#3
|
|||
|
|||
This code is in an OnPress handler from a button in the control
///////// treenode first_cb = node("/Tools/GUIs/PATH TO MY CB/first_cb", model()); pt("First Combo set to: ");pd(getnodenum(itemcurrent(first_cb)));pr(); //////// The value returned is always the initial value of itemcurrent. Therefore, i'm suspicious that itemcurrent is not updated when the combo state changes. Neil |
The Following User Says Thank You to Neil Brandon For This Useful Post: | ||
Efrain Marchena (06-01-2012) |
#4
|
||||
|
||||
Neil,
Your code is pointing at the GUI that act as a class for the GUI's that you create when you open a GUI. When you open a GUI a copy is made from the one in the Tools/GUIs folder and on that copy everything takes place. So the fact that your code always returns the same value is correct because it points to the class GUI (or the mother or whatever you want to call it). Take a look at the view tree and then in active, there you will find all the active windows including the GUIs that you open. Steven |
#5
|
||||
|
||||
treenode first_cb = node("@/PATH TO MY CB/first_cb", c);
c is a reference in the OnPress code of the button to the button that you are pushing (in the active copy; not the original in Tools). The @ symbol takes you to the top-level GUI node from c. Then you can path your way down to your combobox. You could also use .. to go up from the button instead if you wanted. Attached is an example of how you can manipulate a combobox from within the OnPress of a button. It has some good samples for referencing in the tree. |
#6
|
|||
|
|||
Problems with combobox items and itemcurrent
I have a couple of questions related to the combobox example that was posted. I have modified it and attached my similar model. Here are my questions, thank you for any assistance.
1. In the GUI 1 OnOpen routine, should I use the c variable as is mentioned as available in the OnPress routine, or should I use the fully-qualified path and the model() variable? The c variable and "@" notation does not seem to work as well as the path and model() variable. For instance, the Rank returned from getrank() is 0 when use the “@” notation and is correct when use the full path. Is the c variable only available in OnPress? 2. When I change the values in the global table FilenameList and then open the GUI (executing the OnOpen routine), the tree has been updated with the new information – but the combobox has not. However, if I then close and reopen the GUI, the new information is then displayed in the combobox. (note: I do use refreshview and comborefresh at the end of the OnOpen routine). Is there a way to get the combobox to reflect the information from the tree when it is opened in the OnOpen routine? 3. If select “Filename 2” in the combobox, hit the button on the GUI – the correct information for itemcurrent is displayed on the output console, but the tree does not reflect the itemcurrent chosen. A related problem seems to be that if I choose a filename on the combobox and click the button, and then close/reopen the GUI and hit the button without choosing a different filename – I seem to get inconsistent results on this second button press. I would think that I have reset the itemcurrent to 1.0 in the OnOpen routine, but it doesn’t seem to be working. This can be tested by setting the itemcurrent to something other than 1 in the Tree Edit Window and then testing the condition. The value put into the Tree Edit window seems to stick as the itemcurrent after the GUI is closed/reopened, even though I have the set(itemcurrent()) to 1.0 in the OnOpen routine. How do I set the itemcurrent in the OnOpen routine, so that it always defaults to 1 and does not 'remember' the value that was chosen the last time the GUI was opened? |
#7
|
||||
|
||||
When you are editing a GUI with the GUI Builder, you are changing the tree of the GUI template in the Tools folder of the model.
When you actually open a GUI by pressing the "Model Control GUI" button or calling createview(), it creates a copy of the template GUI. The GUI you are seeing is actually a copy that is in VIEW:/active, not the original in MAIN:/1/model/Tools/GUIs. By modifying the values with a path from the model, you are modifying the template that is used when you open a new GUI, not the actual GUI that is open. This is why you have to close the GUI and reopen it to see your changes. In OnOpen code of the main GUI (GUI 1 in this case), c is that top-level window: GUI 1. Therefore, you don't need to use the @ symbol (which is a shortcut for ownerview()) because c IS the ownerview. You can just start your path from there. The attached model shows how this should be done. Also, refreshview(model()) doesn't do anything. The refreshview() command needs to be called on GUI widgets, such as the combobox itself: treenode cb = node("/combobox5",c); refreshview(cb); |
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post: | ||
Rhonda MacIntyre (03-11-2010) |