A number of fixes so the selector for RichTextBoxes will work properly.
* If you press a left arrow when a link starts a line, the cursor will go to the end of the previous line. * If you press the END key, the cursor will not go beyond the end of the line. * If you place the cursor at the beginning of a line, and then click beyond the end of the previous line, the cursor will go to the end of the previous line
This commit is contained in:
parent
f49aae2e7c
commit
a6c0dcddd0
@ -489,6 +489,7 @@ namespace Volian.Controls.Library
|
|||||||
if (!_ContextMenuStripChanged && this.MyStepItem != null)
|
if (!_ContextMenuStripChanged && this.MyStepItem != null)
|
||||||
this.MyStepItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu();
|
this.MyStepItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu();
|
||||||
_ContextMenuStripChanged = false;
|
_ContextMenuStripChanged = false;
|
||||||
|
CorrectSelectionAtEndOfLine();
|
||||||
}
|
}
|
||||||
void StepRTB_MouseUp(object sender, MouseEventArgs e)
|
void StepRTB_MouseUp(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
@ -1110,6 +1111,9 @@ namespace Volian.Controls.Library
|
|||||||
//vlnStackTrace.ShowStackLocal("HandleSelectionChangeStack", 1, 10);
|
//vlnStackTrace.ShowStackLocal("HandleSelectionChangeStack", 1, 10);
|
||||||
bool startingValue = _AdjustingSelection;
|
bool startingValue = _AdjustingSelection;
|
||||||
if (_IdentifyingLinks || _ProcessingDelete) return;
|
if (_IdentifyingLinks || _ProcessingDelete) return;
|
||||||
|
// If the cursor is beyond the end of the line then move the cursor back one character
|
||||||
|
if (CorrectSelectionAtEndOfLine())
|
||||||
|
return;
|
||||||
if (ProcessKeystrokes)
|
if (ProcessKeystrokes)
|
||||||
{
|
{
|
||||||
if (!_MouseDown && !_AdjustingSelection)
|
if (!_MouseDown && !_AdjustingSelection)
|
||||||
@ -1130,7 +1134,7 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
// If the cursor is at the beginning of the line and a link is at the beginning of the line
|
// If the cursor is at the beginning of the line and a link is at the beginning of the line
|
||||||
// then select the link rather than postitioning the cursor at the end of the previous line
|
// then select the link rather than postitioning the cursor at the end of the previous line
|
||||||
if (GetFirstCharIndexOfCurrentLine() == SelectionStart)
|
if (!_LastWasLeftArrow && GetFirstCharIndexOfCurrentLine() == SelectionStart)
|
||||||
SetSelection(ll);
|
SetSelection(ll);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1187,6 +1191,22 @@ namespace Volian.Controls.Library
|
|||||||
else
|
else
|
||||||
MyLinkText = null;
|
MyLinkText = null;
|
||||||
OnRTBSelectionChanged(this, new EventArgs());
|
OnRTBSelectionChanged(this, new EventArgs());
|
||||||
|
_LastWasLeftArrow = false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// If the Selection is beyond the end of the line, move the selection back one character
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool CorrectSelectionAtEndOfLine()
|
||||||
|
{
|
||||||
|
if (SelectionStart > 0 && SelectionLength == 0 &&
|
||||||
|
GetFirstCharIndexFromLine(GetLineFromCharIndex(SelectionStart)) >
|
||||||
|
GetFirstCharIndexOfCurrentLine())
|
||||||
|
{
|
||||||
|
SelectionStart--; // Move the cursor back one character
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void HandleOverWrite()
|
//private void HandleOverWrite()
|
||||||
@ -2634,12 +2654,18 @@ namespace Volian.Controls.Library
|
|||||||
DebugPrint(where, ": {0} {1} '{2}'", SelectionStart, SelectionLength, SelectedText);
|
DebugPrint(where, ": {0} {1} '{2}'", SelectionStart, SelectionLength, SelectedText);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
private bool _LastWasLeftArrow = false;
|
||||||
private void StepRTB_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
private void StepRTB_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("StepRTB_PreviewKeyDown");
|
//Console.WriteLine("StepRTB_PreviewKeyDown");
|
||||||
if ((e.KeyCode == Keys.Tab) && (!e.Alt && !e.Control))
|
if ((e.KeyCode == Keys.Tab) && (!e.Alt && !e.Control))
|
||||||
e.IsInputKey = true;
|
e.IsInputKey = true;
|
||||||
|
// Remember if the last key pressed was a left arrow. This is used in HandleSelectionChanged
|
||||||
|
// When a Link overlaps the beginning of a line. Normally a left arrow will move the cursor
|
||||||
|
// back one character, or if a Link is selected, it will move the cursor to the space before
|
||||||
|
// the link. Since the Link overlaps the line, special consideration must be given to assure
|
||||||
|
// that the cursor goes to the proper place.
|
||||||
|
_LastWasLeftArrow = (!e.Shift && !e.Control && !e.Alt && e.KeyCode == Keys.Left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public partial class StepRTBModeChangeEventArgs : EventArgs
|
public partial class StepRTBModeChangeEventArgs : EventArgs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user