Setting limits on xvalue inputs

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc.
Post Reply
Annik
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

Setting limits on xvalue inputs

Post by Annik » Tue Feb 25, 2014 1:29 pm

I was wondering if you can set boundaries on the possible inputs to an xvalue field editor - for example I have

Code: Select all

location_paired = 0
xvalue("Location of Paired Synapses","location_paired", 1,"procedure()", 1, 1 )
and I want the only possible values to be 0, 1, 2, 3.

Alternatively, if I instead write

Code: Select all

xmenu("Location of Paired Synapses")
xradiobutton("Soma", "procedure()")
xradiobutton("Proximal Dendrite", "procedure()")
xradiobutton("Middle Dendrite", "procedure()")
xradiobutton("Distal Dendrite", "procedure()")
xmenu()
Is there a way to display the selection beside the menu?

Thanks,
Annik

ted
Site Admin
Posts: 5231
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Setting limits on xvalue inputs

Post by ted » Wed Feb 26, 2014 11:23 am

1. Use radiobutton.
2. Use xvarlabel. Try this first on a toy panel.

Annik
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

Re: Setting limits on xvalue inputs

Post by Annik » Sat Mar 01, 2014 2:52 pm

Code: Select all

location_prompt = 0
xmenu("Location of Synapses")  xvarlabel(location_string) 
xradiobutton("Soma", "set_location(0)")
xradiobutton("Proximal Dendrite", "set_location(1)")
xradiobutton("Middle Dendrite", "set_location(2)")
xradiobutton("Distal Dendrite", "set_location(3)")
xmenu()
This displays the location_string below the menu button. Is there a way to get the location string to appear beside the menu button?

ted
Site Admin
Posts: 5231
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Setting limits on xvalue inputs

Post by ted » Sat Mar 01, 2014 3:22 pm

Layout of an xpanel is either vertical, as in
element1
element2
etc.
or horizontal, as in
element1 element2 element3

You could create an HBox and put two xpanels in it. The first xpanel would be on the left and would contain your xradiobutton statements, and the second xpanel would be on the right and would report the location string. Example:

Code: Select all

objref hbox
hbox = new HBox()
hbox.intercept(1)
xpanel("stuff") // left panel
xradiobutton("Soma", "set_location(0)")
xradiobutton("Proximal Dendrite", "set_location(1)")
// etc.
xpanel()
xpanel("morestuff") // right panel
xvarlabel(location_string) 
xpanel()
hbox.intercept(0)
hbox.map("Specify location")

Post Reply