Dropdown in dock not updating on property change

I’ve got a dock in a project that has a dropdown on it. The dropdown is getting the options from a custom property on the view, and the value for the dropdown is bi-directionally bound to a custom property as well.
Sometimes I need that dropdown to be user selectable, other times I need it to be set when that dock is opened.
At the times I need the value to be set, I will send a message to the dock with the value that I need it to be and then open the dock. However, the dropdown list isn’t changed to the value that I’m passing in via the message.

I added a label to the dock just to check the custom property that I’m getting from the message, and that property is getting set. The value of the dropdown is also getting set, it just isn’t triggering the dropdown to select that corresponding item from the list.

Once the dock is open, if I manually change that property via a numeric entry etc… the dropdown is triggered to select the item.

Is this a bug? Or is this intended functionality? Or is there something else going on here?

There's a few things that could cause this, but I'm afraid I'm going to need some clarification before I can really help all that much.

As in system.perspective.sendMessage()? This could fail if there are multiple docks on that side of the page and this dock wasn't the last open dock. Also, does the listener reside on the root?

You specify that you also open the dock during this sequence; is the dock interaction within the same script, or is it a separate action? if you have multiple actions attached to one event, there is no guarantee of which will happen first. In the event you DO have multiple docks on that side and the dock with your dropdown was not the most recently used dock, the send message call could complete and find no listener, then the dock would be expanded after that.

Could I get some examples of the available options and which option you are trying to set the value to? Does this happen every time or is it sporadic/hit-and-miss?

It’s two different scripts, there are a couple of docks, but the message is unique to the dock.

The data gets to the dock no problem… Its just the drop-down down go to the value I pass in via the message.

I’ll be in a better situation tomorrow to put together a concrete example.

OK a bit more information.

I’m using system.perspective.sendMessage() to the dock however, the message is unique to the dock in question. The listener for this message resides on the root of the view.

There are multiple docks on that side of the page however, none are active when I’m doing this test.

The script that I use to initiate sending the message and the dock is as follows:

def runAction(self, event):
	dockId = 'dockNewPO'
	system.perspective.openDock(id=dockId,params={'dockId':dockId})
	system.perspective.sendMessage('On-Dock-New-PO',payload={'terminalId':self.view.params.id})

On the dock, the data is getting to the props.value for the dropdown. If I add a property change script on that prop I can see the data changing… it’s just not changing the dropdown itself to the correct item in the dropdown list.

The options that are in the dropdown look like this: (note the values are valid, the label is changed for privacy). This is also a custom property sitting on the view itself.

[
  {
    "label": "Location A",
    "value": 34
  },
  {
    "label": "Location B",
    "value": 30
  },
  {
    "label": "Location B",
    "value": 2
  },
  {
    "label": "Location C",
    "value": 31
  },
  {
    "label": "Location D",
    "value": 38
  }
]

And in this specific instance, I’m trying to set the value of the dropdown to 34 via the message.

The way I’m going this is 100% repeatable.

Is there any chance you’re sending the value as a string instead of the numeric value? How is the Primary View receiving this id value before eventually sending it to the Dropdown?

1 Like

Ahhh… It is possible. I’ll check in a bit.

Try modifying your script to always send the payload value as an int, and see if that fixes it:

system.perspective.sendMessage('On-Dock-New-PO',payload={'terminalId':int(self.view.params.id}))
1 Like

ding ding ding that fixed it.

I can’t believe I didn’t see that. Sigh.

Thanks for your help!

1 Like