Yomguithereal / react-blessed

A react renderer for blessed.
MIT License
4.45k stars 177 forks source link

How to receive all childs keypress events? #61

Closed steve-chavez closed 6 years ago

steve-chavez commented 7 years ago

On blessed is possible to do this with:

box.on('element keypress', () => {});

Instead of on('keypress') I have a root element that needs to handle this, I've tried with onElementKeypress but it doesn''t work. Check blessed event bubbling.

Yomguithereal commented 7 years ago

For this kind of advanced use case I guess you should probably use refs and bind your event. It would be a bit difficult for the library to guess the combination of event elements based on the name (not saying it can't be done, just that maybe it should not be done). But maybe some middle way can be found. Something along onCustom taking a tuple of [event, handler] or even a list of those.

malonehedges commented 6 years ago

@steve-chavez any luck figuring out child keypress events? Struggling with the best way to do this.

steve-chavez commented 6 years ago

@malonehedges What I did was to have a ref to a root <element> like this then bind the element keypress event in a componentDidMount like this.

malonehedges commented 6 years ago

@steve-chavez Thanks so much for the reply! I'll try that out.