protected override void OnKeyDown(KeyEventArgs e)
{
// detect whether the user is doing a range selection with the keyboard within
// a freeform annotation, and try to keep the selection within the bounds of the editable selection. (LT-2910)
if (RootBox != null && (e.Modifiers & Keys.Shift) == Keys.Shift)
{
TextSelInfo tsi = new TextSelInfo(RootBox);
int hvoAnchor = tsi.HvoAnchor;
if (hvoAnchor != 0)
{
ICmObject coAnchor = Cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvoAnchor);
if ((coAnchor is ISegment && (tsi.TagAnchor == SegmentTags.kflidFreeTranslation || tsi.TagAnchor == SegmentTags.kflidLiteralTranslation))
|| (coAnchor is INote && tsi.TagAnchor == NoteTags.kflidContent))
{
// we are in a segment-level annotation.
if (e.KeyCode == Keys.Home)
{
// extend the selection to the beginning of the comment.
SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(tsi.Selection, this);
selHelper.IchEnd = 0;
selHelper.MakeRangeSelection(RootBox, true);
return;
}
}
}
}
// LT-9570 for the Tree Translation line, Susanna wanted Enter to copy Word Glsses
// into the Free Translation line. Note: DotNetBar is not handling shortcut="Enter"
// for the XML <command id="CmdAddWordGlossesToFreeTrans"...
if (RootBox != null && e.KeyCode == Keys.Enter)
OnAddWordGlossesToFreeTrans(null);
// LT-4029 Capture arrow keys from inside the translation lines and notes.
var change = HandleArrowKeys(e);
// LT-12097 Right and left arrow keys from an empty translation line (part of the issue)
// The up and down arrows work, so here we changed the event appropriately to up or down.
if (change != ArrowChange.Handled)
{
KeyEventArgs e2;
switch (change)
{ // might need to change the key event so the base method will handle it right.
case ArrowChange.Down:
e2 = new System.Windows.Forms.KeyEventArgs(Keys.Down);
break;
case ArrowChange.Up:
e2 = new System.Windows.Forms.KeyEventArgs(Keys.Up);
break;
case ArrowChange.None:
e2 = e;
break;
default:
e2 = e;
break;
}
base.OnKeyDown(e2);
}
}