Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to subscribe to the Document.ImpliedSelectionChanged event so that I can show some information about selected objects on my UI palette. The problem is that this works only once, until user presses Escape or invokes any command. After that the event handler is not even hit.
Is what I'm trying to achieve possible? If yes, what am I doing wrong?
The current code (just a proof of concept):
//method linked with a command to enable selection listening
public void SelInfoListenOn()
{
var doc = Application.DocumentManager.MdiActiveDocument;
doc.ImpliedSelectionChanged += Doc_SelChanged;
}
//my handler
private void Doc_SelChanged(object sender, EventArgs e)
{
var logPath = @"C:\Users\User\Desktop\selchangelog.txt";
string info = "Selection changed:\nInfo:";
PromptSelectionResult psr = (sender as Document).Editor.SelectImplied();
foreach (SelectedObject selObj in psr.Value)
{
info += $"\n - {selObj.GetType().ToString()}";
}
System.IO.File.AppendAllText(logPath, info + "\n");
}
Solved! Go to Solution.