After I updated to Thesaurus 1.1.1 I get a null reference exception in the following code (used to work previously):
ToolStripItem[] thesaurusSuggestions = null;
// NOTE: This if statement is only a workaround for a bug in Thesaurus.GetSuggestionToolStripItems()!
// If the mouse is right-clicked at the end of the text the method will throw an
// exception (index out of bounds)! GetItem(...) returns null if not at a character
// position. See the code sample "Getting the word at the current mouse position" at
//
http://www.textcontrol.c...ds/library/other/chars/
Point mousePos = this.textControl1.PointToClient(Control.MousePosition);
if (this.textControl1.TextChars.GetItem(mousePos, false) != null)
{
thesaurusSuggestions = this.thesaurus1.GetSuggestionToolStripItems();
}
Please note that my comment in the code refers to Thesaurus 1.1.0. I believe there was a bug but the workaround worked just fine. However, after the update I get this exception:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="Keyoti.Thesaurus.Windows.NET2"
StackTrace:
at Keyoti.Thesaurus.Windows.Thesaurus.GetSuggestionToolStripItems()
at Iwrite4Life.Plugins.Iwrite.IwriteWordProcessor.PopulateSynonyms()
at Iwrite4Life.Plugins.Iwrite.IwriteWordProcessor.contextMenuStrip1_Opening(Object sender, CancelEventArgs e)
at System.Windows.Forms.ToolStripDropDown.OnOpening(CancelEventArgs e)
at System.Windows.Forms.ToolStripDropDown.SetVisibleCore(Boolean visible)
at System.Windows.Forms.ContextMenuStrip.SetVisibleCore(Boolean visible)
at System.Windows.Forms.ToolStripDropDown.Show(Control control, Point position)
at System.Windows.Forms.ContextMenuStrip.ShowInternal(Control source, Point location, Boolean isKeyboardActivated)
at System.Windows.Forms.Control.WmContextMenu(Message& m, Control sourceControl)
at System.Windows.Forms.Control.WmContextMenu(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at TXTextControl.TextControlBase.WndProc(Message& message)
at TXTextControl.TextControl.WndProc(Message& message)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
Wolfgang
Wolfgang