PF_Cmd_USER_CHANGED_PARAM called twice on button press in Premiere

Community Beginner ,
Feb 27, 2017 Feb 27, 2017

Copy link to clipboard

Copied

I'm trying to open a file dialog when a user presses a button in my plugin. I set up the button fine with:

PF_ADD_BUTTON("Choose File", "Browse", 0, PF_ParamFlag_SUPERVISE, PARAM_ID_LAUNCH_BUTTON);

but then the callback for PF_Cmd_USER_CHANGED_PARAM gets called twice whenever the button is pressed (at least in Premiere, haven't tried in After Effects), and I can't figure out why or how to effectively ignore the second one knowing it's not a real second button press. Any ideas?

TOPICS
SDK

Views

296

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 02, 2017 Mar 02, 2017

Copy link to clipboard

Copied

This is a hack workaround, as opposed to figuring out why the event is triggering twice, but this might work.

In your User Changed Param callback, have a static A_short variable initialized to 0. Check for this being non-zero to open your file dialog, in other words ignore the first button hit and act on the second.

static PF_Err UserChangedParam(...) {

    static A_short button_hit_count = 0;

    if(param == your_button) {

          if(button_hit_count == 0) {

              // Ignore the first hit

              button_hit_count++;

              return PF_Err_NONE;

          }

          // As button_hit_count is now 1, Open file dialog

          ...

          // Reset button hit count

          button_hit_count = 0;

    }

    return PF_Err_NONE;

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 02, 2017 Mar 02, 2017

Copy link to clipboard

Copied

That was very kind of you to write that all out. I'm doing essentially that hack to ignore the second call, but it makes me nervous that it could fail in other unanticipated situations, so it doesn't seems like a great release-ready solution. Nobody knows why this happens in the first place? Really surprised how jumbled and hack-filled this plugin architecture is, coming from a giant like Adobe.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

LATEST

I'm having the same issue in AE using the latest SDK so not sure if bug or a feature, or if adobe won't change it to keep compatibility with older versions. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines