I'm adding a button to the action/context menu in the Mail list view. I have no problems getting the message ID in the button handler when the message is either visible in the viewing pane (e.g. has been clicked on), or is checked. When I right-click on a message that isn't visible, I can't get the ID. However, when I select one of the built-in actions, like Mark as Unread, that action is able to get the message IDs.
That was probably a bit complicated to follow, so here's a video of what I'm talking about: https://www.youtube.com/watch?v=ozxw...ature=youtu.be
My code to add the button:
I've tried using the same methods that ZmMailListController.prototype._redirectListener and ZmMailListController.prototype._markUnreadListener use to get the IDs, since they work with in a "zero-selection" scenario, but haven't had any luck.
Anyone have an idea as to how I can get the ID in this situation? It's not a big deal for this particular zimlet, but I would like to figure it out since the built-in actions seem to support it.
That was probably a bit complicated to follow, so here's a video of what I'm talking about: https://www.youtube.com/watch?v=ozxw...ature=youtu.be
My code to add the button:
Code:
ca_sfu_archiveMessage.prototype.onActionMenuInitialized = function(controller, actionMenu) {
// enable the button for multi-selections and zero-selections(?)
controller.operationsToEnableOnMultiSelection.push('ARCHIVE_MESSAGE');
controller.operationsToEnableOnZeroSelection.push('ARCHIVE_MESSAGE');
this.addArchiveButton('actionMenu', actionMenu, controller);
};
ca_sfu_archiveMessage.prototype.addArchiveButton = function(where, target, controller) {
var offsets = {
toolbar: 1,
actionMenu: 1
}
, index = -1
, buttonArgs, button;
for (var i=0; i < target.opList.length; i++) {
if (target.opList[i] === ZmOperation.SPAM) {
index = i + offsets[where];
break;
}
};
buttonArgs = {
text: 'Archive',
tooltip: 'Archive Message',
index: index,
image: 'Warning',
enabled: false
};
button = target.createOp('ARCHIVE_MESSAGE', buttonArgs);
var listener = new AjxListener(this, this.buttonHandler, controller);
button.addSelectionListener(listener);
};
ca_sfu_archiveMessage.prototype.buttonHandler = function(controller, ev) {
var dlg = appCtxt.getMsgDialog();
dlg.setTitle('Get Message Test');
var msg = controller.getMsg();
var content = msg ? "Selected Message ID: " + msg.id : "No Message Selected";
dlg.setContent(content);
dlg.popup();
};
Anyone have an idea as to how I can get the ID in this situation? It's not a big deal for this particular zimlet, but I would like to figure it out since the built-in actions seem to support it.