matt (support) wrote:I'm not sure I understand your question,...
And I probably didn't explain it very well. Here is the UI field definition from Devices.xml, the code that creates the list and and the Callback handler
- Code: Select all
<Field id="deviceSelect" type="menu" >
<Label>Select Device:</Label>
<List class='self' method='getDevices' />
<CallbackMethod>getDevicesExit</CallbackMethod>
</Field>
- Code: Select all
def getDevices:
for key in self.deviceArray:
menuText = self.deviceArray[key]['serverName']
menuEntry = (key, menuText)
returnMenu.append(menuEntry)
menuEntry = (u'--', u'-------------')
returnMenu.append(menuEntry)
menuEntry = (u'DIGITALINPUT', u'Digital Input')
returnMenu.append(menuEntry)
menuEntry = (u'DIGITALOUTPUT', u'Digital Output')
returnMenu.append(menuEntry)
return returnMenu
- Code: Select all
def getDevicesExit(self, valuesDict, typeId, devId):
key = valuesDict['deviceSelect']
if key == '--':
errorsDict = indigo.Dict()
errorsDict['phidgetSelect'] = "Invalid Selection"
errorsDict["showAlertText"] = "Invalid Selection"
return errorsDict
elif key == ...
This creates the menu list as desired, showing the dynamic entries and then the separator and the static entries at the bottom. What I want to do is trap the case where the user selects the separator (value = "--"). Since getDevicesExit is called when there is a menu change, I thought I could trap it there and return an error indication. However, it appears that Indigo is only expecting a single dict in the return from the callback method. The code above produces no visible error message, but it does reset the menu to the original state (- Select an Item-). I suspect it does that because errorsDict is essentially an empty dict - I.e. no entries matching any fields in the UI.
So, the question is, is there a way to display an error in the case noted above? Or, should I just be content with resetting the menu and letting the user figure out what happened?