You should create a background service in your extension in order to catch properly all of panel events.
1- Define service file in your def.json
[
{
.
.
"service": { main: "service.htm", debug: false }
.
.
}
]
2- Catch events in service.htm.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<script>
var rt = window.external.mxGetRuntime();
rt.onAppEvent = function (obj) {
switch (obj.type) {
case "ACTION_START":
// panel started.
break;
case "ACTION_STOP":
// panel stopped.
break;
case "ACTION_SHOW":
// panel is shown.
break;
case "ACTION_HIDE":
// panel is hidden.
break;
case "ERROR":
console.log(obj.errorMessage);
break;
case "LOCALE_CHANGED":
// locale changed.
break;
default:
// do nothing.
}
};
</script>
</head>
<body>
</body>
</html>
You can also debug your service by changing debug parameter.