Get screen rect of Hyperlink
Posted: 18 Jul 2025, 12:14
Hi,
I working on tutorial for player. I want to highlight and spot to HyperLink in Run (RichText), assist player click to that. I try to get screen position but it always give me Empty Rect.
This is what i tried:
And, it great if we can get multiline rect.
I working on tutorial for player. I want to highlight and spot to HyperLink in Run (RichText), assist player click to that. I try to get screen position but it always give me Empty Rect.
This is what i tried:
Code: Select all
pThis->UpdateLayout();
auto* hyperlink = Noesis::DynamicCast<Noesis::Hyperlink*>(args.source);
//auto renderBounds = hyperlink->GetRenderBounds();
float width = hyperlink->GetActualWidth();
float height = hyperlink->GetActualHeight();
auto* text =
Noesis::DynamicCast<Noesis::TextBlock*>(hyperlink->GetParent());
//auto* parent = g_noesis().findVisualParent<Noesis::TextBlock>(pThis);
auto local = Noesis::VisualTreeHelper::GetContentBounds(hyperlink);
// If bounds are still empty, try getting from parent TextBlock
if (local.IsEmpty()) {
local = Noesis::VisualTreeHelper::GetDescendantBounds(text);
}
auto tlInTb =
hyperlink->TranslatePoint(Noesis::Point(local.x, local.y), text);
auto transform = hyperlink->TransformToAncestor(text);