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.

[1108 byte] By [michaelolson] at [2007-12-16]
# 1

What version of VS are you using?

Thanks,
-Josh

joshs at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 2
2003
michaelolson at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 3
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

joshs at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 4
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);

michaelolson at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 5
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

joshs at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified