All right, that last post was pretty bad. I figured a few things out since I first posted it, and I don't think an edit of the first one is worth since I was pretty off beam.
TL;DR: I have a view-wise working sub tagMenu in my actionsMenu, as I wanted. My question is: What is the proper way to bind the listeners?
For anyone who may be heading on the same road (and is as blind as me), there is a
set(items, tagList) method that is
much more simple to use, and is, I assume, the correct way to build a ZmTagMenu.
Here's how the code looks now:
Code: Select all
ZmEnhancedToolbar.prototype._setActionsMenu =
function(controller, toolbar) {
var actionsMenu = toolbar.getActionsMenu();
// Checks for an existing actions menu in the toolbar
if(actionsMenu){
actionsMenu.createSeparator();
var tagSubButton = actionsMenu.createMenuItem(ZmOperation.TAG_MENU, {
text: ZmMsg.briefcasePropTags,
image: "Tag"
});
var subTagMenu = ZmOperation.addTagMenu(tagSubButton);
// This function let's me populate the new subTagMenu
subTagMenu.set(controller.getItems(), appCtxt.getTagTree());
// Here's how I'm binding the listeners
controller._setupTagMenu(actionsMenu);
}
}
So that does the trick except for one thing, which is quiet as similar as the final problem I had in my
first post, which is the binding of the listeners to the actual buttons. I guess I probably can browse through all my buttons from the tagMenu in the toolbar, and assign them to the ones on the same index in my newly created sub tagMenu, but it seems a little hacky since I managed to create it that cleanly... Is there a right way or am I just looking to hard at something that doesn't exist..?
EDIT:
So, there's progress sooner than I thought. I found what I was looking for, which was the
ZmBaseController._setupTagMenu(parent, listener), and it works like a charm... except for one thing, which is that the removeTag button is always off, no matter the tag there's on the item. So, i've updated the code above, and I'm really looking for a way to fix that rather weird issue.
2 EDIT:
Ok, I finally found what was wrong, and that weird "issue" I had turns out to be perfectly explainable. And now I know what I'm looking for. The reason the removeTag button is always off, is the same reason (which I hadn't notice on my first edit) the tags will all appear, no matter the tags the item already owns. It is the fact that my menu's content is not refreshed. Which means I have to find the right listener. I think I found what I need, but don't know how to implement it (on which objects, or even how to call it). I found this piece of code in the
ZmOperation.js file:
Code: Select all
ZmOperation.registerOp(ZmId.OP_TAG_MENU, {textKey: "tag", tooltipKey:"tagTooltip", image:"Tag", showImageInToolbar: true }, ZmSetting.TAGGING_ENABLED, AjxCallback.simpleClosure(function(parent) {
ZmOperation.addDeferredMenu(ZmOperation.addTagMenu, parent, true);
}));
So I'm pretty interested in this
ZmOperation.addDeferredMenu(addMenuFunc, parent) method with the
ZmOperation.addTagMenu(parent), and I guess I also need the
AjxCallback.simpleClosure(func, object) method. But I don't know how I need to use them. I guess I can keep my tagSubButton, but that's pretty much it. Does anyone know how to use this promise in my context?