-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix onPress handlers on nested Text components (#560)
Currently, onPress handlers only work on outermost Text components. This change enables you to place onPress handlers on nested Text components. For example, this now works: <Text> <Text onPress={this._handlePress}>Press Me</Text> </Text> In the fix, we need to manually do hit testing on outermost Text components to see if any of the nested Text components got hit. This is because the nested Text components are represented by Inlines rather than by UIElements.
- Loading branch information
Showing
7 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
|
||
namespace ReactNative.UIManager | ||
{ | ||
/// <summary> | ||
/// Interface consisting of methods which are relevant to views which contain | ||
/// visuals that have react tags but are not rendered using UIElements. | ||
/// </summary> | ||
public interface IReactCompoundView | ||
{ | ||
/// <summary> | ||
/// Returns the react tag rendered at point in reactView. The view | ||
/// is not expected to do hit testing on its UIElement descendants. Rather, | ||
/// this is useful for views which are composed of visuals that are associated | ||
/// with react tags but the visuals are not UIElements. | ||
/// </summary> | ||
/// <param name="reactView">The react view to do hit testing within.</param> | ||
/// <param name="point">The point to hit test in coordinates that are relative to the view.</param> | ||
/// <returns>The react tag rendered at point in reactView.</returns> | ||
int GetReactTagAtPoint(UIElement reactView, Point point); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
ReactWindows/ReactNative/UIManager/ReactDefaultCompoundView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
|
||
namespace ReactNative.UIManager | ||
{ | ||
class ReactDefaultCompoundView : IReactCompoundView | ||
{ | ||
public int GetReactTagAtPoint(UIElement reactView, Point point) | ||
{ | ||
return reactView.GetTag(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ReactWindows/ReactNative/Views/Text/ReactTextCompoundView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using ReactNative.UIManager; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace ReactNative.Views.Text | ||
{ | ||
class ReactTextCompoundView : IReactCompoundView | ||
{ | ||
public int GetReactTagAtPoint(UIElement reactView, Point point) | ||
{ | ||
var richTextBlock = reactView.As<RichTextBlock>(); | ||
var textPointer = richTextBlock.GetPositionFromPoint(point); | ||
return textPointer.Parent.GetTag(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters