Merge pull request #232 from AlvinRey/Fix-TimeBox

(fix) Some functionality doesn't work when TimeBox is contained in DataGrid
This commit is contained in:
Dong Bin
2024-05-18 13:51:00 +08:00
committed by GitHub

View File

@@ -332,6 +332,8 @@ public class TimeBox : TemplatedControl
MoveCaret(_currentActiveSectionIndex.Value); MoveCaret(_currentActiveSectionIndex.Value);
} }
} }
e.Pointer.Capture(_presenters[_currentActiveSectionIndex.Value]);
e.Handled = true;
} }
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)
@@ -480,13 +482,16 @@ public class TimeBox : TemplatedControl
if (AllowDrag) if (AllowDrag)
_dragPanels[index].IsVisible = false; _dragPanels[index].IsVisible = false;
_presenters[index].ShowCaret(); ShowCaretInteral(index);
_isShowedCaret[index] = true;
_presenters[index].SelectAll(); _presenters[index].SelectAll();
} }
private void MoveCaret(int index) private void MoveCaret(int index)
{ {
if (!_isShowedCaret[index])
{
ShowCaretInteral(index);
}
_presenters[index].ClearSelection(); _presenters[index].ClearSelection();
var caretPosition = var caretPosition =
_pressedPosition.WithX(_pressedPosition.X - _borders[index].Bounds.X); _pressedPosition.WithX(_pressedPosition.X - _borders[index].Bounds.X);
@@ -503,8 +508,7 @@ public class TimeBox : TemplatedControl
_presenters[index].ClearSelection(); _presenters[index].ClearSelection();
if (_isShowedCaret[index]) if (_isShowedCaret[index])
{ {
_presenters[index].HideCaret(); HideCaretInteral(index);
_isShowedCaret[index] = false;
} }
if (AllowDrag) if (AllowDrag)
@@ -694,4 +698,16 @@ public class TimeBox : TemplatedControl
return milliSecond; return milliSecond;
} }
private void ShowCaretInteral(int index)
{
_presenters[index].ShowCaret();
_isShowedCaret[index] = true;
}
private void HideCaretInteral(int index)
{
_presenters[index].HideCaret();
_isShowedCaret[index] = false;
}
} }