Well, the business logic has changed on this, so that I am creating the buttons later. Somehow the timing made the issue go away.
But, I still need some help getting toolbar buttons added by a zimlet. We are approaching a release, so I really need to get this resolved. The current issue is that I can't get buttons added to the By Message View to do anything, it's like the listeners I define get wiped out before I can click.
Here is some code
Code:
// Create our operations.
this._quickOpDesc = ZmOperation.defineOperation(null, ZmOperation.SETUP[ZmOperation.NEW_VIDEOMAIL]); // Op set up earlier, all good
// Get the mail toolbar
this._mailCtrl = appCtxt.getApp(ZmZimbraMail.MAIL_APP).getTradController();
try {
this._mailCtrl._initializeToolBar(this._mailCtrl._defaultView());
} catch (ex) {
Com_Rs_Video.log.warn("Problem initializing Message toolbar, ignoring " + ex);
}
if (!this._mailCtrl._toolbar instanceof ZmButtonToolBar) {
this._mailToolbar = this._mailCtrl._toolbar;
} else {
this._mailToolbar = this._mailCtrl._toolbar[this._mailCtrl._defaultView()];
}
//// Add an operation button and keep in toolbar _buttons[]
ZmOperation.addOperation(this._mailToolbar, this._quickOpDesc.id, this._mailToolbar._buttons, 2);
// Add listener
this._mailToolbar.addSelectionListener(this._quickOpDesc.id, new AjxListener(this, Com_Rs_Video._newVideoMsgListener)); Note that this code is executed
after the page has been rendered. Also note that I am able to add buttons that work to the ZmConvListController using nearly identical code.
After lots of time in Firebug, I narrowed it down to
DwtButton.prototype._mouseUpListener, specifically the evaluation of
Code:
if(this.isListenerRegistered(DwtEvent.SELECTION))
This is the difference between buttons that work and those that don't. This test evaluates to
false with my new button. When I do:
this._mailToolbar._buttons[this._quickOpDesc.id].isListenerRegistered(DwtEvent.SELECTION) from in the debugger console, right after the code above, it evaluates to
true.
So I have to conclude that something is changing the state when switching to the By Message view. I don't know if this is a bug, or if there is something else I need to do. Help would be much appreciated.
- John Troxel