Page 1 of 1

There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 11:29 am
by Colorado4Wheeler
This seems to be missing from the PluginBase, is there a different method that is raised when someone cancels or closes out of a menu action other than the button action? I only see the following methods:

Code: Select all
closedActionConfigUi
closedDeviceConfigUi
closedDeviceFactoryUi
closedEventConfigUi
closedPrefsConfigUi

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 1:15 pm
by jay (support)
No, because menu actions never validate UI on closure, so neither validate nor closed methods exist for them.

However, I believe that if you specify an actionId for the menu item's ConfigUI (rather than specifying the full UI), the validate method for the action dialog is called. It's possible the closed method is called as well, but I'm less sure about that.

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 1:38 pm
by Colorado4Wheeler
jay (support) wrote:
However, I believe that if you specify an actionId for the menu item's ConfigUI (rather than specifying the full UI)

I'm not sure I"m understanding what you mean by that.

But, once I understand what you mean by that, that means that even though validateMenuActionConfigUi doesn't exist here:
Code: Select all
validateActionConfigUi
validateDeviceConfigUi
validateDeviceFactoryUi
validateEventConfigUi
validatePrefsConfigUi
validateSerialPortUi

That it might be calling validateActionConfigUi in its place?

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 4:03 pm
by jay (support)
Rather than building the whole ConfigUI for a menu, you can optionally specify an Action type ID, and the menu will use that for it's config dialog:

Code: Select all
   <MenuItem id="menu2">
      <Name>Start Timer...</Name>
      <ConfigUI actionId="startTimer"/>
   </MenuItem>


startTimer is an action in Actions.xml that has a config UI. This allows you to publish actions that can also be run interactively from the plugin's menu without having to duplicate code. In that case, the validateActionConfigUi call will be made.

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 4:38 pm
by Colorado4Wheeler
jay (support) wrote:
Rather than building the whole ConfigUI for a menu, you can optionally specify an Action type ID, and the menu will use that for it's config dialog:

That's interesting, I didn't know that was possible - a very cool way to provide the functionality in two places without duplicating the code. Can you reference a hidden action in that way without any problems? Honestly I don't want this menu action accessible via actions but want the validate method so if that is what it takes to get it then I'll do that as long as I can hide the action.

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 5:00 pm
by jay (support)
Colorado4Wheeler wrote:
Can you reference a hidden action in that way without any problems?


Probably - give it a try! (I honestly don't know and don't want to dig into the code at the moment)

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Fri Jul 27, 2018 5:03 pm
by Colorado4Wheeler
I'll test it out in the next few days and see what happens. Like you, I don't want to change a bunch of stuff around to test right now ;).

Re: There isn't a closedMenuActionConfigUi?

PostPosted: Mon Mar 18, 2019 7:16 am
by DaveL17
I'm not sure that this is the exact need that C4W was looking for, but I found this thread after I had a similar need to call validation routines from a Menu Item config menu UI. I found that you can also pass back the typical error message dict from the config menu's callback.

Code: Select all
<MenuItem id="test_menu">
    <Name>Test Menu Name</Name>
    <CallbackMethod>test_menu_callback</CallbackMethod>
    <ConfigUI>
        <Field id="field_one" type="menu">
            <Label>Field 1 Label</Label>
            <List>
                <Option value="2">2</Option>
                <Option value="1">1</Option>
            </List>
        </Field>
    </ConfigUI>
    <ButtonTitle>Save</ButtonTitle>
</MenuItem>

Code: Select all
    def test_menu_callback(self, values_dict, menu_id):

        error_msg_dict = indigo.Dict()

        if 1 != 2:
            error_msg_dict['field_one'] = u"This is a test error."
            error_msg_dict['showAlertText'] = u"Test Error.\n\nThis is a test of validation code within a callback."

            return False, values_dict, error_msg_dict

        else:
            return True