MCPcopy Create free account
hub / github.com/AshampooSystems/boden / textChanged

Method textChanged

framework/ui/platforms/android/src/LabelCore.cpp:48–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 void LabelCore::textChanged(const Text &text)
49 {
50 if (_currentAttributedString) {
51 _currentAttributedString->linkClicked().unsubscribe(_linkSubscription);
52 }
53
54 std::visit(
55 [this](auto &&arg) {
56 using T = std::decay_t<decltype(arg)>;
57
58 if constexpr (std::is_same_v<T, std::string>) {
59 // Remove '\r' as android treats them as a space
60 std::string textToSet = arg;
61 textToSet.erase(
62 std::remove_if(textToSet.begin(), textToSet.end(), [](unsigned char x) { return x == '\r'; }),
63 textToSet.end());
64 _jLabel.setText(textToSet);
65 } else if constexpr (std::is_same_v<T, std::shared_ptr<AttributedString>>) {
66 if (auto attrString = std::dynamic_pointer_cast<bdn::android::AttributedString>(arg)) {
67 _currentAttributedString = attrString;
68 _linkSubscription = _currentAttributedString->linkClicked().subscribe(
69 [this](auto url) { this->_linkClickCallback.fire(url); });
70 _jLabel.setText(attrString->spanned());
71 }
72 }
73 },
74 text);
75
76 markDirty();
77 scheduleLayout();
78 }
79
80 void LabelCore::updateTruncateAndWrapMode()
81 {

Callers

nothing calls this directly

Calls 8

unsubscribeMethod · 0.80
linkClickedMethod · 0.80
subscribeMethod · 0.80
spannedMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
setTextMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected