Skip to content
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

focus and tab order #73

Open
geyang opened this issue Jan 19, 2018 · 3 comments
Open

focus and tab order #73

geyang opened this issue Jan 19, 2018 · 3 comments

Comments

@geyang
Copy link

geyang commented Jan 19, 2018

@Yomguithereal Thanks for this great library!

I was looking for ways to put a component in focus but couldn't find it in the documentation. Is there anywhere I can look this up?

Thanks!
Ge

@Yomguithereal
Copy link
Owner

Hum. I thinks that currently you might have to set a ref on the component and used blessed's API to focus the component as I think I did not implement any of the react callbacks used to deal with focus and component mounting etc.

@gouegd
Copy link

gouegd commented Dec 16, 2019

Here's a quick sample with hooks to focus if someone is looking for it

const App = () => {
	const listRef = useRef();
	useEffect(() => {
		if (listRef.current) {
			listRef.current.focus();
		}
	}, []);

	return (
		<box
			top="center"
			left="center"
			width="50%"
			height="50%"
			border={{type: 'line'}}
			style={{border: {fg: 'blue'}}}
		>
			<list
				ref={listRef}
				keys
				mouse
				items={['oui', 'maybe', 'no ?']}
				style={{
					item: {fg: 'white'},
					selected: {fg: 'cyan'}
				}}
			/>
		</box>
	);
};

@Yomguithereal
Copy link
Owner

Thanks @gouegd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants