mirror of https://github.com/embarklabs/embark.git
submit on enter for whisper
This commit is contained in:
parent
bf06163d30
commit
3c08b575df
|
@ -22,6 +22,14 @@ class Whisper extends React.Component {
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEnter(e, func) {
|
||||||
|
if (e.key !== 'Enter') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
func.apply(this, [e]);
|
||||||
|
}
|
||||||
|
|
||||||
sendMessage (e) {
|
sendMessage (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
EmbarkJS.Messages.sendMessage({topic: this.state.channel, data: this.state.message});
|
EmbarkJS.Messages.sendMessage({topic: this.state.channel, data: this.state.message});
|
||||||
|
@ -68,7 +76,7 @@ class Whisper extends React.Component {
|
||||||
</React.Fragment> : ''
|
</React.Fragment> : ''
|
||||||
}
|
}
|
||||||
<h3>Listen To channel</h3>
|
<h3>Listen To channel</h3>
|
||||||
<Form inline>
|
<Form inline onKeyDown={(e) => this.checkEnter(e, this.listenToChannel)}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormControl
|
<FormControl
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -87,7 +95,7 @@ class Whisper extends React.Component {
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<h3>Send Message</h3>
|
<h3>Send Message</h3>
|
||||||
<Form inline>
|
<Form inline onKeyDown={(e) => this.checkEnter(e, this.sendMessage)}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormControl
|
<FormControl
|
||||||
type="text"
|
type="text"
|
||||||
|
|
Loading…
Reference in New Issue