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

.onActivate callback for Panel Object

Explorer ,
Feb 25, 2016 Feb 25, 2016

Hello there.

I'm working on a UI that uses lots of eventListeners. I'd like to add and remove them depending on the state of the window.

To do this, I'm using callbacks:

.onActivate

.onDeactivate

The script below works like a charm when run from File>Scripts>Run Script File...

When saved in the /Scripts/ScriptUI Panels/scriptname.jsx and then run it from the Window menu in AE, the .onActivate callback doesn't seem to work.

At least not when just clicking the window.

But when You click the button first, the .onActivate callback is triggered.

The .onDeactivate callback works just as expected; it get's triggered when I click another part of the AE interface.

Any ideas?

{

function safeEventWindow(thisObj){

  var win = thisObj instanceof Panel ? thisObj : new Window('palette',"Safe Event Window",undefined,{resizable:true})

  win.alignChildren = ['fill','fill']

  var mGrp = win.add('panel',undefined,'PANEL!')

  mGrp.minimumSize = [200,200]

  var btn1 = win.add('button',undefined,"I'm just a button, man.")

  btn1.alignment = ['center','center']

  btn1.onClick = switchText

  var txt1 = mGrp.add("StaticText",undefined,"\\^___________^/")

  txt1.alignment = ['center','center']

  txt1.hide()

  // FUNCTIONS

  function switchText(event){

  var state = txt1.visible

  if(state) txt1.hide()

  else txt1.show()

  }

  function mWin_refresh(){

  win.layout.layout(true)

  win.layout.resize()

  }

  // EVENT HANDLERS & FUNCTIONALITY

  function startMouseListeners(event){

  $.writeln("startingMouseListeners")

  mGrp.addEventListener("mouseover",switchText)

  mGrp.addEventListener("mouseout",switchText)

  }

  function stopMouseListeners(event){

  $.writeln("stoppingMouseListeners")

  mGrp.removeEventListener("mouseover",switchText)

  mGrp.removeEventListener("mouseout",switchText)

  }

  win.onActivate = startMouseListeners

  win.onDeactivate = stopMouseListeners

  win.onResizing = mWin_refresh

  //__INIT__

  if(win instanceof Window){

  win.show()

  win.center()

  }

  mWin_refresh()

}

//__INIT__

safeEventWindow(this)

}

TOPICS
Scripting
1.3K
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

Advocate , Feb 26, 2016 Feb 26, 2016

Checked on AE CC2014, windows 7 : onActivate does not work, onActivate triggers only when activating a widget (the button), but not the panel.

Side note : you should care when adding event listeners to a group/panel : the "mouseover" and "mouseout" can trigger for both the panel AND the static text (when it is visible)

Is it what you want ?

Xavier

Translate
Advocate ,
Feb 26, 2016 Feb 26, 2016

Checked on AE CC2014, windows 7 : onActivate does not work, onActivate triggers only when activating a widget (the button), but not the panel.

Side note : you should care when adding event listeners to a group/panel : the "mouseover" and "mouseout" can trigger for both the panel AND the static text (when it is visible)

Is it what you want ?

Xavier

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
Explorer ,
Feb 26, 2016 Feb 26, 2016

Aww, damn.. Is there another way to check if the Panel has been activated?

It really annoys me that it works for windows but not dockable panels.

Side note : you should care when adding event listeners to a group/panel : the "mouseover" and "mouseout" can trigger for both the panel AND the static text (when it is visible)

^I'm not sure what you mean?  Is it: When I'm adding an eventListener to a group with another element in it, the event can be triggered twice, when the mouse is over both elements at the same time?

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
Advocate ,
Feb 26, 2016 Feb 26, 2016

yes, when the mouse enters the static text when it is visible, it triggers

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
Adobe Employee ,
Mar 01, 2016 Mar 01, 2016

Hello! I'm Joel from the After Effects team. We've identified the problem and have prioritized a fix for this year, pending other higher priority work coming in.

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
Explorer ,
Mar 01, 2016 Mar 01, 2016

Thanks for the reply, JoelAE . Really hope this will get fixed. For now I guess I'll have to make due with the Window Object.

And UQg‌, as always, thanks for sharing your knowledge

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
New Here ,
Sep 19, 2017 Sep 19, 2017

Hi Joel,

Do you have some news on the bug fixing, because we are in the version 14.2 and the problem remain the same.

Tks for feedback

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
Contributor ,
Feb 21, 2021 Feb 21, 2021
LATEST

It has been 5 years and this hasn't been solved. 😕

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