Skip to content

Commit

Permalink
Fixed old clicks being used to update selector
Browse files Browse the repository at this point in the history
  • Loading branch information
tcstewar committed Sep 12, 2018
1 parent d5d9d6b commit 131d1dd
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions nengo_gui/static/components/raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Nengo.Raster = function(parent, sim, args) {
// Index of the neuron that makes a sound when spiking
this.sound_index = -1;
this.draw_clicked = false;
this.neuron_highlight_click = false; //selected state of neurons

// TODO: put the neuron highlight properties in CSS
this.neuron_highlights_g.append('rect')
Expand Down Expand Up @@ -71,14 +70,13 @@ Nengo.Raster = function(parent, sim, args) {
var mouse = d3.mouse(this);
self.neuron_highlight_updates = true;
self.mouse_position = [mouse[0], mouse[1]];
self.update_highlight(mouse);
self.update_highlight(mouse, false);
})
.on('click', function() {
var mouse = d3.mouse(this);
self.neuron_highlight_updates = true;
self.neuron_highlight_click = true;
self.mouse_position = [mouse[0], mouse[1]];
self.update_highlight(mouse);
self.update_highlight(mouse, true);
})

/** call schedule_update whenever the time is adjusted in the SimControl */
Expand Down Expand Up @@ -176,7 +174,7 @@ Nengo.Raster.prototype.set_n_neurons = function(n_neurons) {
this.ws.send('n_neurons:' + n_neurons);
}

Nengo.Raster.prototype.update_highlight = function(mouse) {
Nengo.Raster.prototype.update_highlight = function(mouse, click) {
var self = this;
var x = mouse[0];
var y = mouse[1];
Expand All @@ -190,15 +188,14 @@ Nengo.Raster.prototype.update_highlight = function(mouse) {

this.neuron_highlights_g.style('display', null);

if (this.neuron_highlight_click){
if (click){
if (new_sound_index == this.sound_index) {
this.draw_clicked = false;
this.sound_index = -1;
} else {
this.draw_clicked = true;
this.sound_index = new_sound_index;
}
this.neuron_highlight_click = false;
}

//draw the currently clicked highlight
Expand Down Expand Up @@ -272,7 +269,7 @@ Nengo.Raster.prototype.update = function() {

//** Update the highlight text if the mouse is on top */
if (this.neuron_highlight_updates) {
this.update_highlight(this.mouse_position);
this.update_highlight(this.mouse_position, false);
}

};
Expand Down

0 comments on commit 131d1dd

Please sign in to comment.