-
Notifications
You must be signed in to change notification settings - Fork 860
Expand file tree
/
Copy pathKeyBase.js
More file actions
37 lines (29 loc) · 731 Bytes
/
KeyBase.js
File metadata and controls
37 lines (29 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
import { Component } from 'react';
import CalculatorActions from '../actions/CalculatorActions';
class Key extends Component {
constructor(props) {
super(props);
this.state = {
isHighlighted: false
};
// Bind callback methods to make `this` the correct context.
this.handleClick = this.handleClick.bind(this);
this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
}
handleClick() {
CalculatorActions.typeKey(this.props.keyType, this.props.keyValue);
}
onMouseDown() {
this.setState({
isHighlighted: true
});
}
onMouseUp() {
this.setState({
isHighlighted: false
});
}
}
export default Key;