tasknavigated event
I am using the tasklist object in my add-in and have an eventhandler for the tasknavigated event. Here is the code in the handler:
if (myTaskItem.FileName != "")
{
TextWindow myTxtWin;
TextPane myTxtPane;
myTxtWin = (TextWindow) applicationObject.ActiveDocument.ActiveWindow.Object;
myTxtPane = myTxtWin.ActivePane;
myTxtPane.Selection.MoveToLineAndOffset(myTaskItem.Line, 1,false);
myTxtPane.Selection.SelectLine();
navigateHandled =true;
}
This code is working when I double-click and item in the tasklist or navigate the list with the arrow keys and press the enter key. The problem is when I select next or previous task. The eventhandler is being fired for every item in the tasklist above(previous) or below(next) the current item. So when it finally returns control back to the IDE, the last or first item is now current.
I'm not able to reproduce this using VS 2003 myself. Does the content of your event handler make any difference? (For instance, if you remove all code and simply return immediately, does the behavior still happen?)
-Josh
If I return immediately the behavior is the same. The items in my tasklist are items I added programmatically in my add-in. I don't know if that makes any difference.
myTaskList.TaskItems.Add(vsTaskCategories.vsTaskCategoryBuildCompile, "", linesplit[4].ToString().Trim(),
vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconCompile,
true, linesplit[1].Trim(),
Convert.ToInt32(linesplit[2]), true, true);
I see. Yes, this is buggy behavior. Unfortunately, I don't think there is any workaround. I can report that it seems fixed in VS 2005, though.
-Josh