mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 11:57:46 +08:00
Remember ShadowNode of RawText's parent in attribute string
Summary: When a user clicks on some text, `RCTSurfaceTouchHandler` will call into a method on `RCTParagraphComponentView`. That method (i.e: `touchEventEmitter`) would be responsible for identifying the closest ancestral `<Text/>` component to which we should dispatch the `onPress` event, given the point where the user clicked. To answer this query, we'll use a data structure called `UIAttributedString`. This data structure represents a string, and a corresponding mapping from sequences of its characters to some arbitrary data. In this attributed string, we'll map sequences of characters to their closest ancestral `ParagraphShadowNode` or `TextShadowNode`. That way, when we get a click event on `RCTParagraphComponentView`, we can just look at the character that was clicked, and use that information to do a lookup in the attributed string to find the shadow node who's EventEmitter is responsible for processing the click event. Reviewed By: shergin Differential Revision: D9696904 fbshipit-source-id: a199649981ad271afa85414ce4c3f056851348be
This commit is contained in:
committed by
Facebook Github Bot
parent
4a4e083e2a
commit
4e841f2114
@@ -39,6 +39,7 @@ public:
|
||||
std::string string;
|
||||
TextAttributes textAttributes;
|
||||
SharedShadowNode shadowNode;
|
||||
SharedShadowNode parentShadowNode;
|
||||
};
|
||||
|
||||
using Fragments = std::vector<Fragment>;
|
||||
|
||||
Reference in New Issue
Block a user