ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 02-10-2009
Neil Brandon Neil Brandon is offline
Flexsim User
 
Join Date: Sep 2008
Location: Appleton, WI
Posts: 5
Downloads: 35
Uploads: 0
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 0
Neil Brandon is on a distinguished road
Default 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  
Old 02-10-2009
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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  
Old 02-10-2009
Neil Brandon Neil Brandon is offline
Flexsim User
 
Join Date: Sep 2008
Location: Appleton, WI
Posts: 5
Downloads: 35
Uploads: 0
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 0
Neil Brandon is on a distinguished road
Default

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  
Old 02-10-2009
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 02-10-2009
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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.
Attached Files
File Type: zip combobox.zip (6.7 KB, 230 views)
  #6  
Old 03-04-2010
Rhonda MacIntyre Rhonda MacIntyre is offline
Flexsim User
 
Join Date: Sep 2008
Posts: 6
Downloads: 3
Uploads: 0
Thanks: 6
Thanked 0 Times in 0 Posts
Rep Power: 0
Rhonda MacIntyre is on a distinguished road
Default 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?
Attached Files
File Type: zip combobox_mod2.zip (18.2 KB, 177 views)
  #7  
Old 03-05-2010
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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);
Attached Files
File Type: zip combobox_mod3.zip (14.0 KB, 185 views)
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post:
Rhonda MacIntyre (03-11-2010)



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.