Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

RegisterKeyEventsInterest Intermittently Not Working?

Enthusiast ,
May 30, 2017 May 30, 2017

Last week my panel was properly responding to keyboard input. I would click into it and could get listener callbacks when hitting certain keys for which I'd registered interest with CEP.

Today I started up Premiere (it had actually been up for quite a while, including while the computer slept, but I've shut it off and turned it on again) and found that the CEP panel would not respond to any of the keyboard events. Pressing just about any key while the panel is focused results in a "boop" sound effect (I'm on a mac) and no response from the panel.

As an example, I'm "registering interest" using:

cs.registerKeyEventsInterest('[{"keyCode": 0x0F}]');  // 0x0F is "r" for the mac.

And then adding an event listener with:

document.body.addEventListener('keydown', handleKeyEvent, false);

Has anyone else encountered this? What could suddenly cause Premiere Pro to stop properly passing keyboard events on to the panel?

TOPICS
SDK
848
Translate
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

correct answers 1 Correct answer

Enthusiast , May 31, 2017 May 31, 2017

I found the problem. This is not a bug with Premiere Pro, but a bug with the code I'm using. Specifically, I rearranged my strings to be more readable, doing something like the following:

cs.registerKeyEventsInterest(

    '[ \

        {"keyCode": 0x0F}, \

        {"keyCode": 0x0F, "ctrlKey": true} \

    ]'

);

This is a multi-line string. Unfortunately, this adds a whole bunch of space characters to the resulting string. See:

[                {"keyCode": 0x0F},                {"keyCode": 0x0F, "ctrlKey":

...
Translate
Enthusiast ,
May 31, 2017 May 31, 2017
LATEST

I found the problem. This is not a bug with Premiere Pro, but a bug with the code I'm using. Specifically, I rearranged my strings to be more readable, doing something like the following:

cs.registerKeyEventsInterest(

    '[ \

        {"keyCode": 0x0F}, \

        {"keyCode": 0x0F, "ctrlKey": true} \

    ]'

);

This is a multi-line string. Unfortunately, this adds a whole bunch of space characters to the resulting string. See:

[                {"keyCode": 0x0F},                {"keyCode": 0x0F, "ctrlKey": true}           ]

Apparently, this interferes with the JSON parsing. By switching to the following, I was able to get keyboard input to work again:

cs.registerKeyEventsInterest(JSON.stringify(

    [

        {"keyCode": 0x0F},

        {"keyCode": 0x0F, "ctrlKey": true}

    ]

));

So a bug existed, just in my own code. Whoops!

Translate
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