visibleBinding issue

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

visibleBinding issue

Post by berkinet »

In this Devices.xml snippet:

Code: Select all

<Field id='list1' type='menu' >
	<Label>Response to an ON event:</Label>
	<List>
		<Option value="1">Option 1</Option>
		<Option value="2">Option 2</Option>
	</List>
</Field>

<Field id='text1' type='textfield' visibleBindingId='list1' visibleBindingValue='1' >
	<Label>Select the Group/Scene:</Label>
</Field>

<Field id='text2' type='textfield' visibleBindingId='list1' visibleBindingValue='2' >
	<Label>Select the ON Action Group:</Label>
</Field>
Both text1 and text2 are initially visible until a selection is made from the menu, at which point the appropriate field vanishes. I would assume that neither would have been initially visible.

However, if I add a third state and a set it as the default, like:

Code: Select all

<Field id='list1' type='menu' defaultValue='0'>
	<Label>Response to an ON event:</Label>
	<List>
		<Option value="0"> - Select Something - </Option>
		<Option value="1">Option 1</Option>
		<Option value="2">Option 2</Option>
	</List>
</Field>
Then it works as expected.

Bug, un-documented feature, or programmer mental vacancy?
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: visibleBinding issue

Post by jay (support) »

Well, it's sorta a bug. The deal is that when you don't specify a default value, the value of the field is basically NULL (nil in Cocoa). So it kinda matches anything when in reality it should match nothing (this may be a Cocoa Bindings bug - there are a TON of those). Bottom line though is that you really should always specify a default value for a menu field so that bindings work as you would expect and so you'll get the expected value in all circumstances. We should probably require that you specify a default value on menu field types.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: visibleBinding issue

Post by berkinet »

Thanks, I wasn't sure if you knew about the issue. I've been using defaultValue anyway.


BTW, it is not really an issue with static lists. But, in dynamic lists Indigo adds an extra " - Select - " Option too, so you can end up with two non-entries. Now, if you gave a value to the Indigo inserted non-option, like -1, then we could choose it as the defaultvalue and still have the visibility bindings work as expected.
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: visibleBinding issue

Post by jay (support) »

That is added by Cocoa on a NULL field (I turned it on specifically at the request of Perry I believe). It's only added when the dialog is opened for the first time and there is no value in the field (assuming that your validation requires a valid value to be selected). The fix would be the same - make a field with a NULL value fail all the bindings (back to the potential of it being a Cocoa Binding bug). I'll definitely look into it.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
Locked

Return to “Extending Indigo with Plugins and Python”