Skip to main content
New Participant
February 28, 2017
Question

PF_Cmd_USER_CHANGED_PARAM called twice on button press in Premiere

  • February 28, 2017
  • 1 reply
  • 691 views

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?

This topic has been closed for replies.

1 reply

Inspiring
March 2, 2017

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;

}

JamchildAuthor
New Participant
March 2, 2017

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.

James Whiffin
Brainiac
January 23, 2022

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.