views:

91

answers:

0

I'm making a small Visual Studio addin that changes the default generated event handler names in VS from something like txtName_Click to something user defined. I've already done this for the WinForms and WebForms designer using IEventBindingService, but I want to do this in the C# code editor as well. When you type something like "txtName.TextChanged +=" in the code window, you get a tooltip saying something like "new EventHandler(txtName_TextChanged) Press tab to insert", if you then press tab you get the statement and can change the name, if you press tab one more time you generate the event handler.

I want to intercept this and put in my own custom name. I've already tried creating my own command filter with IOleCommandTarget, it receives the '+' and '=' characters, but doesn't receive the 'Tab' command that generates the event handler, presumably because the C# lang service already handled it and doesn't pass it up the chain. Is there anyway for me to intercept this in a clean manner?

I've already thought about listening for changed events, and when the event handler name is selected I could just use the TextSelection object to change it, but I really would like to get in sooner than that, so that the tooltip also shows my name instead of the default.

Any ideas about what interfaces or methods I can use to plug into this? I've seen an IVsTipWindow interface but don't know how to get to it. And if there's no offical way, do you have any idea how I could get the window handle of the tooltip so I could just use some low level stuff to overwrite the text or something similar?