Action Menu button: get message IDs with "zero" selection?

Interested in talking about Mash-up's? This is the place.
grahamb
Advanced member
Advanced member
Posts: 53
Joined: Fri Sep 12, 2014 11:28 pm

Action Menu button: get message IDs with "zero" selection?

Postby grahamb » Thu May 29, 2014 3:38 pm

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:
My">https://www.youtube.com/watch?v=ozxws219pYw&feature=youtu.be
My
code to add the button:



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
if (target.opList === 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();

};

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.


15438jhon
Advanced member
Advanced member
Posts: 93
Joined: Sat Sep 13, 2014 2:52 am

Action Menu button: get message IDs with "zero" selection?

Postby 15438jhon » Fri Jun 13, 2014 6:23 am

Hey,

While no email is selected, you would need to use "appCtxt.getCurrentController().getDnDSelection()" method in your handler. It will get an Object of ZmMailMsg OR ZmConv.
grahamb
Advanced member
Advanced member
Posts: 53
Joined: Fri Sep 12, 2014 11:28 pm

Action Menu button: get message IDs with "zero" selection?

Postby grahamb » Thu Jul 03, 2014 1:41 pm

[quote user="15438jhon"]Hey,

While no email is selected, you would need to use "appCtxt.getCurrentController().getDnDSelection()" method in your handler. It will get an Object of ZmMailMsg OR ZmConv.[/QUOTE]
Thanks for the reply. I'm just getting back to this project.
The action menu button handler receives the current controller, which is either ZmTradController nor ZmConvListController, depending on what the view the user is using. Neither of those controllers have a getDnDSelection method on them. The only place I can see it being defined is on DwtListView, line 702 , and the only relevant place it is being used is in ZmListController, line 588.
grahamb
Advanced member
Advanced member
Posts: 53
Joined: Fri Sep 12, 2014 11:28 pm

Action Menu button: get message IDs with "zero" selection?

Postby grahamb » Thu Jul 03, 2014 3:51 pm

Ah, got it! Inside the button handler: controller._listView[controller._currentViewId].getDnDSelection() returns the selected messages, even without a "real" selection. It's very similar to how ZmMailListController.prototype._markUnreadListener gets the selection (which works even if a message isn't really selected). In that case, it calls .getSelected(), which works, but getSelected() doesn't work when called by the zimlet (it returns an empty array).
Thanks for the pointer.
15438jhon
Advanced member
Advanced member
Posts: 93
Joined: Sat Sep 13, 2014 2:52 am

Action Menu button: get message IDs with "zero" selection?

Postby 15438jhon » Fri Jul 04, 2014 1:38 am

You're welcome my friend ;)
thorx
Advanced member
Advanced member
Posts: 54
Joined: Sat Sep 13, 2014 3:26 am

Action Menu button: get message IDs with "zero" selection?

Postby thorx » Tue Nov 25, 2014 3:41 am

hmm. so in a conversation, you get the messageobject of the message.
I'm struggling understanding how to get the id of the message that is right clicked on. I'm getting the whole conversation:


This will get me the first message in the conversation. but how do I get only the message that where right clicked?
var lv = controller.getListView();
var itemConv = lv.getDnDSelection();
var msgList = itemConv.getMsgList();
var hotmessage=itemConv.getFirstHotMsg();
alert( hotmessage.getMsgSender() );


Return to “Zimlets”

Who is online

Users browsing this forum: No registered users and 2 guests