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

Implement react SyntheticEvent dispatch #98

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions examples/hotkeys.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, {Component} from 'react';
import blessed from 'neo-blessed';
import {HotKeys, configure} from 'react-hotkeys';
import {createBlessedRenderer} from '../src';

const render = createBlessedRenderer(blessed);

configure({
defaultComponent: 'element',
defaultKeyEvent: 'keypress'
});

const keyMap = {
'quit': ['q']
};

class App extends Component {
componentDidMount() {
this._hotkeysContainer && this._hotkeysContainer.focus();
}

render() {
const handlers = {
'quit': () => {
process.exit();
}
};
return (
<HotKeys keyMap={keyMap} handlers={handlers} innerRef={c => this._hotkeysContainer = c}>
<box label="react-blessed demo"
border={{type: 'line'}}
style={{border: {fg: 'cyan'}}}>
This example uses neo-blessed fork of blessed library.
</box>
</HotKeys>
);
}
}

const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: 'press q to quit'
});

screen.enableInput();
screen.key(['C-c'], (ch, key) => {process.exit();});

global.window = screen;
const component = render(<App />, screen);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lodash": "^4.x.x",
"mocha": "^4.0.1",
"neo-blessed": "^0.2.0",
"react-hotkeys": "git+https://github.com/visigoth/react-hotkeys#0bf84cc4b7cb264c663a349b6b02575a1a577b49",
"react-motion": "^0.5.2",
"rollup": "^0.65.0",
"rollup-plugin-babel": "^4.0.2",
Expand Down
1 change: 1 addition & 0 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const examples = [
'neo-blessed',
'progressbar',
'remove',
'hotkeys'
];

if (examples.indexOf(example) === -1) {
Expand Down
14 changes: 14 additions & 0 deletions src/fiber/ScreenEventTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Constants for native events emitted by screen
export const SCREEN_KEYPRESS = 'keypress';
export const SCREEN_FOCUS = 'focus';
export const SCREEN_BLUR = 'blur';

export const all = [
SCREEN_KEYPRESS,
SCREEN_FOCUS,
SCREEN_BLUR
];

export function screenEventName(eventType) {
return eventType;
};
Loading