-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
React-native: tvOS How to force a Button to be focused? #13855
Comments
Have you tried using touchable highlight? see https://facebook.github.io/react-native/docs/touchablehighlight.html |
Yes I have tried: But nothing to set the focus on an element for Apple Tv I use this in my app |
I would forget about Apple TV for a moment and just see if it is possible outside Apple TV. Perhaps you should also consider using newer list like FlatList for example as well. Put function on Highlight methods like onTouch etc and see if they fire for items in a list. If they do than this can be shown. I did notice that one method for touchable focus highlight seems to be iOS only. Are you on Android? |
Thanks for you answer 👍 I'm on tvOS, |
I think I understand it better now. Ok, you want to almost simulate a user touch of the component. Something like that ... |
Yes ! Not really a user touch A user selection, when the user on tvOS move to up it select a cell, and I want to select it programatically |
Do you have an idea to do that ? |
https://facebook.github.io/react-native/docs/flatlist.html |
Thanks, I will try with that and update you as soon as possible |
Also take a look at the example above in https://facebook.github.io/react-native/docs/flatlist.html in the section on pure components. class MyList extends React.PureComponent { Interesting are: _onPressItem = (id: string) => { _renderItem = ({item}) => ( // On Press Item will toggle the selected state. |
Yes it is possible, with tvOS and react native if you want to force a focusable component to be focus you just need to set hasTVPreferredFocus to true For example:
You can see this post on Stackoverflow: |
RN Apple TV author here.... @JulienKode is correct, |
I've submitted a PR to add |
@dlowder-salesforce That's a nice a idea 👍 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
How to force a Button to be focused?
I have been trying to do this since several weeks
For example if I have a ListView and if I want to have a specific cell focused, how I can do that ?
There are posts on Stackoverflow but nobody knows the answer
The text was updated successfully, but these errors were encountered: