Hello,
Welcome to Microsoft Q&A!
CUSTOM EDIT CONTROL - NOT WORKING
By checking your sample, the customer_edit_control still responds is because you subscribe the PointerPressed event of CoreWindow in CustomEditControl.xaml.cs, when you click on screen, this event will be triggered. So even if you only click the Button, this event still be triggered and then set the focus to your control.
You can add a property to judge if the mouse is in your CustomEditControl, if it is, you can perform operations in the PointerPressed event of CoreWindow. For example:
private bool isBeyondScope = false;
BorderPanel.PointerEntered += fdgdfgd;
BorderPanel.PointerExited += fdgdfgd1;
private void fdgdfgd1(object sender, PointerRoutedEventArgs e)
{
Window.Current.CoreWindow.PointerCursor = cursorBeforePointerEntered;
isBeyondScope = true;
}
private void fdgdfgd(object sender, PointerRoutedEventArgs e)
{
isBeyondScope = false;
buttonCursor = new CoreCursor(CoreCursorType.IBeam, 5);
cursorBeforePointerEntered = Window.Current.CoreWindow.PointerCursor;
// Set button cursor.
Window.Current.CoreWindow.PointerCursor = buttonCursor;
}
void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs args)
{
Rect contentRect = GetElementRect(BorderPanel);
if (contentRect.Contains(args.CurrentPoint.Position) && isBeyondScope == false)
{
var mm = GetElementRect(ClearButton);
if (mm.Contains(args.CurrentPoint.Position))
{
Text = string.Empty;
var range = Selection;
SetSelectionAndNotify(range);
args.Handled = true;
return;
}
UpdateTargetBoxID?.Invoke(uniqueKey, Type);
if (IsReadOnly || !IsEnabled) return;
SetInternalFocus(uniqueKey);
Focus(FocusState.Programmatic);
}
else
{
// The user tapped outside the control. Remove focus.
if (!kbActive)
{
Selection.StartCaretPosition = Selection.EndCaretPosition = _text.Length;
RemoveInternalFocus();
}
kbActive = false;
}
}