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

Event listeners generate errors while modal windows are shown.

Explorer ,
Sep 02, 2016 Sep 02, 2016

Copy link to clipboard

Copied

Hello all,

I have an interface in script ui that relies on event listeners initialized like this:

var button = palette.add("image", rect);
button.onDraw = buttonDraw;
button.addEventListener('mouseover', onMouse, false);
button.addEventListener('mouseout', onMouse, false);
button.addEventListener('mousedown', onMouse, false);
button.addEventListener('mouseup', onMouse, false);

I need these events so I can change images (fake buttons) when the user moves the mouse over them or clicks one of them. Everything works as it should, until I decided to render something. While rendering in After Effects, a window or something is opened somewhere and it makes all scripts useless, they do not respond to user input at all, and that's fine to me. It works the same for all scripts that I tested.

The real problem is with event listeners. Scripts that use them will generate a background error if any listener is activated. And when the render finishes, AE will show a popup message letting you know about these errors. Also the script interface will stop running completely until you close it an open it again.

The error message is:

"Can not run a script while a modal dialog is waiting for response."

I thought of replacing all listeners with the other type of callback like "onClick", but it seems there's no workaround for "mouseover" or "mouseout".

This is a real issue for my UI, as if the user has my panel docked somewhere in the interface and simply moves the mouse over any of the buttons, he will end up with the error message at the end of the render. There's also nothing I can do to avoid the listeners from running, since after the script is loaded, we lose all control of what's going on with it, no way to remove the listeners temporarily.

Any ideas on how to solve this?

TOPICS
Scripting

Views

1.1K

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

correct answers 1 Correct answer

Explorer , Sep 03, 2016 Sep 03, 2016

I found a workaround for my problem.

I had to remove the event listenerer "mouseout" when my custom onDraw function was executed as a result of the actual mouse going out (in other words drawing my image in the iddle version). Then, I simply install the "mouseout" event again when the "mouseover" event is fired.

I also tried removing the listener "mouseout" in my onMouseOut function, but it didn't work very well, the only way was to remove it in the custom onDraw.

Another thing I found out is that

...

Votes

Translate

Translate
Advocate ,
Sep 02, 2016 Sep 02, 2016

Copy link to clipboard

Copied

Hello, normally when a dialog window is shown, the rest of AE's UI is disabled, hence eventlisteners are deactivated for the duration of the dialog.

I tried and couldnt reproduce what you describe (launch a panel with a similar button, start a render, hover over the panel while rendering: no error). Can you provide more info about the onMouse function ?

However i'm jumping on this topic because of a very similar problem (Windows7/AE CC2015):

when a native dialog is shown (ie not a script alert, but for instance Edit>Preferences>General), everything in a ScriptUI Panel that has a custom onDraw disappears, and this sometimes persist when the dialog is closed. Given that .onActivate() doesnt work for panels, one has to "reshaw" buttons by hand by hovering over everything that is "missing"...

Xavier

Votes

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
Explorer ,
Sep 02, 2016 Sep 02, 2016

Copy link to clipboard

Copied

Hi,

As it turns out, the culprit is actually the listener "mouseout". I was just creating a simple script to show you the problem, and noticed it was working with the "mouseover" listener, so I added all the others I was using and puff! I also tested with the "keydown" event which also generates the error.

Here the test script:

function TestListeners(thisObj)

{

  var myMainPanel = createUI(thisObj);

    if(this instanceof Panel)

        myMainPanel.show();

  function createUI(thisObj)

    {

        var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Test", undefined);

  var button = myPanel.add("button", {x:10, y:10, width:50, height:50}, "Test Button");

  button.addEventListener('mouseout', onMouse, false);

  return myPanel;

    }

  function onMouse(event)

  {

  }

}

TestListeners(this);

On another note, I tried to get rid of all events and added a custom onDraw to my buttons and checked there if the mouse was over or the button was clicked. It also crashes. In fact, just adding a custom onDraw to a button returns that error message at the end of the render. Which makes me think that the "mouseout" event is used here as well.

by the way, I also have the same problem with the images disappearing when for eg. the general option window is open. I'm also using a custom onDraw for these images.

Votes

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
Explorer ,
Sep 03, 2016 Sep 03, 2016

Copy link to clipboard

Copied

I found a workaround for my problem.

I had to remove the event listenerer "mouseout" when my custom onDraw function was executed as a result of the actual mouse going out (in other words drawing my image in the iddle version). Then, I simply install the "mouseout" event again when the "mouseover" event is fired.

I also tried removing the listener "mouseout" in my onMouseOut function, but it didn't work very well, the only way was to remove it in the custom onDraw.

Another thing I found out is that the "mouseout" event is actually fired 2 times... every time!. Which is surely a bug.

I'll mark this as answered even though this is more like a dirty workaround than an actual fix. I think this is a bug from After Effects (at least).

UQg​ regarding your issue, do you have a thread for it? If not, you should create one, I also have that problem and I'm going to look into it.

Votes

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
Advocate ,
Sep 05, 2016 Sep 05, 2016

Copy link to clipboard

Copied

No i dont have a thread. I have already opened a thread about onDraw in another context but it didnt meet a great success so i gave up.

I think only Adobe can solve this kind of issue, but i'll gladly take your solution if you find one.

Custom onDraw are very useful, it's a pity they dont work properly in CC.

Xavier

Votes

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 ,
Jan 22, 2025 Jan 22, 2025

Copy link to clipboard

Copied

LATEST

This remains an issue in 2025, lol. I love CEP, but ScriptUI is still desirable when deploying simple ES tools quickly. Removing the listener when it fires works, but it seems like it can be defeated: When over an element, if you press a hotkey to bring up a modal such as Ctrl+I for File>Import etc., the mouseout never gets a chance to fire and remove itself and thus can still trigger as the modal is active. More rare than usual ineraction, but still causes the error.

Votes

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