|
@@ -42,6 +42,33 @@ export default class AbstractToolbarButton extends Component {
|
42
|
42
|
underlayColor: React.PropTypes.any
|
43
|
43
|
};
|
44
|
44
|
|
|
45
|
+ /**
|
|
46
|
+ * Initializes a new {@code AbstractToolbarButton} instance.
|
|
47
|
+ *
|
|
48
|
+ * @param {Object} props - The React {@code Component} props to initialize
|
|
49
|
+ * the new {@code AbstractToolbarButton} instance with.
|
|
50
|
+ */
|
|
51
|
+ constructor(props) {
|
|
52
|
+ super(props);
|
|
53
|
+
|
|
54
|
+ // Bind event handlers so they are only bound once per instance.
|
|
55
|
+ this._onClick = this._onClick.bind(this);
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * Handles clicking/pressing this {@code AbstractToolbarButton} by
|
|
60
|
+ * forwarding the event to the {@code onClick} prop of this instance if any.
|
|
61
|
+ *
|
|
62
|
+ * @protected
|
|
63
|
+ * @returns {*} The result returned by the invocation of the {@code onClick}
|
|
64
|
+ * prop of this instance if any.
|
|
65
|
+ */
|
|
66
|
+ _onClick(...args) {
|
|
67
|
+ const { onClick } = this.props;
|
|
68
|
+
|
|
69
|
+ return onClick && onClick(...args);
|
|
70
|
+ }
|
|
71
|
+
|
45
|
72
|
/**
|
46
|
73
|
* Implements React's {@link Component#render()}.
|
47
|
74
|
*
|