查找用户在 Visual Studio 扩展上下文菜单中单击的文档位置
我希望能够找到用户在文档中单击的位置以调出右键单击上下文菜单。基本上我希望能够看到点击下光标的确切位置。
我正在使用以下代码处理右键单击菜单项,但是我使用的 eventArgs 没有任何有关菜单触发内容的详细信息。理想情况下,我希望能够查明用户点击代码的程度。
private void MenuItemCallback(object sender, EventArgs e)
{
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE ;
TextDocument activeDoc = dte.ActiveDocument.Object() as TextDocument;
var text = activeDoc.CreateEditPoint(activeDoc.StartPoint).GetText(activeDoc.EndPoint);
}
I want to be able to find where the user clicked in the document to bring up the right click context menu. Basically i want to be able to see the exact position of the cursor under the click.
I am handling the right click menu item with the following code, however the eventArgs im using dont have any detail on what the menu was triggered on. Ideally i want to be able to pinpoint how far through the code the user clicked.
private void MenuItemCallback(object sender, EventArgs e)
{
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE ;
TextDocument activeDoc = dte.ActiveDocument.Object() as TextDocument;
var text = activeDoc.CreateEditPoint(activeDoc.StartPoint).GetText(activeDoc.EndPoint);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ActivePoint 可以是用于处理大多数情况:
这将使活动点被单击,但如果单击的区域已经是选择的一部分,则可能会给出不同的结果。
ActivePoint can be used to deal with most cases:
This will get the active point clicked, but it may give different results if the area clicked is already part of a selection.