Skip to content

Commit

Permalink
for issue #148. Allow Delete/Backspace key to delete color pattern sw…
Browse files Browse the repository at this point in the history
…atches / spots when in edit mode
  • Loading branch information
todbot committed Sep 15, 2020
1 parent cfa9a1e commit 119d8f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/components/gui/patternView.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ var PatternView = React.createClass({
var pattern = this.state.pattern;
this.props.onDeletePattern( pattern.id );
},
handleSwatchKeyDown: function(e,i) {
log.msg("handleSwatchKeyDown", i, e.key)
if( this.state.editing && (e.key === "Backspace" || e.key === "Delete") ) {
var pattern = this.state.pattern;
delete pattern.colors[this.state.activeSwatch];
this.setState({pattern: pattern});
}
},

render: function() {
var pattern = this.state.pattern;
Expand Down Expand Up @@ -206,9 +214,11 @@ var PatternView = React.createClass({
if( isEditing && i === this.state.activeSwatch ) {
mystyle.borderColor='#333'; mystyle.borderWidth = 3;
}
mystyle.outline = 0
return (
<div style={mystyle} key={i}
<div style={mystyle} key={i} tabIndex={-1}
onClick={this.onSwatchClick.bind(this, i)}
onKeyDown={(e) => this.handleSwatchKeyDown(e,i)}
onDoubleClick={this.onSwatchDoubleClick.bind(this,i)}></div>
);
};
Expand Down

0 comments on commit 119d8f9

Please sign in to comment.