Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop EditorBaseControl from letting PointerPressed events bubbling up... #22

Open
minesworld opened this issue Jan 17, 2025 · 0 comments

Comments

@minesworld
Copy link

by adding e.Handled(true);

void EditorBaseControl::OnPointerPressed(DUX::Input::PointerRoutedEventArgs const &e)
{
	__super::OnPointerPressed(e);

	Focus(FocusState::Pointer);

	// The focus state seems to get confused if the following code is placed in ImageTarget_PointerPressed.
	// OnPointerReleased is the same for symmetry. ImageTarget_PointerMoved is there to show correct cursor
	// when moving the cursor over the scrollbar (UWP).

	if (auto imageTarget{ GetTemplateChild(L"ImageTarget").try_as<UIElement>() }) // Todo: Store this
	{
		auto point{ e.GetCurrentPoint(imageTarget) };
		auto scaled{ point.Position() };
		switch (point.Properties().PointerUpdateKind())
		{
		case DUI::PointerUpdateKind::LeftButtonPressed:
			_scintilla->PointerPressed(Point{ scaled.X * _dpiScale, scaled.Y * _dpiScale }, point.Timestamp() / 1000ul, e.KeyModifiers());
			break;
		case DUI::PointerUpdateKind::RightButtonPressed:
			_scintilla->RightPointerPressed(Point{ scaled.X * _dpiScale, scaled.Y * _dpiScale }, point.Timestamp() / 1000ul, e.KeyModifiers());
			break;
		}
		// Todo: make sure the loss of precision is not going to realistically cause a problem
	}

	e.Handled(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant