How do I find and remove objects in an array?
-
@VirtualVirgin For those functions (some, filter, etc.) the first parameter should be a function.
Edit: I just realised you're doing the javascript arrow function thing, we don't have that in HISE.
-
@d-healey said in How do I find and remove objects in an array?:
@VirtualVirgin For those functions (some, filter, etc.) the first parameter should be a function.
Edit: I just realised you're doing the javascript arrow function thing, we don't have that in HISE.
No, the arrow function definitely works:
-
Oh that's good to know, thanks!
Now I can do this kind of thing:
Engine.showYesNoWindow("A title", "Some text", response => { Console.print(response); });
You could replace this
if (sRow && sCol) return true; else return false;
With
return sRow && sCol
But this doesn't solve your issue. Can you make a simple snippet that demonstrates the issue?
-
@d-healey
I found where the problem is taking place:selectedNotes.push ( selectedNotes.filter(function (c) { var cx = c.col * cellWidth; var cy = height - (c.row + 1) * cellHeight; return ( cx + cellWidth > x1 && cx < x2 && cy + cellHeight > y1 && cy < y2 ); }) );
This selectedNotes.push is pushing an object inside an array to the selectedNotes array, whereas I only need it to push an object to the array.
So the current result is looking like [[{"row":42, "col":4}]]
but I need it to just look like [{"row":42, "col":4}]
I am not sure how I modify that to just use a the object and not have it wrapped in that extra array. -
@VirtualVirgin Add
[0]
after the parenthesis -
@d-healey Almost...
that turns it into an object, but it only returns one selection to the list instead of all of the noteCells under the selection rectangle area.
Without the [0] it returns all of them, but inside an array. -
@VirtualVirgin In that case after it returns them, just grab the [0] element from that array.
-
@d-healey Whoops... is there a panic button of some sort for feedback loops? I got stuck in one.
-
@VirtualVirgin What do you mean?
-
@d-healey I added a for loop after that function and it seems to be stuck in the loop
-
@VirtualVirgin What does the loop do?
-
for (i = 0; i < noteCells; i++) selectedNotes.push(noteCells[i]);
It's not resolving because I meant to use "i < noteCells.length",
so I am stuck with a spinning wheel and a sluggish HISE.I'll just force quit it.
Just didn't know if there is a button similar to "all notes off" to stop the processing. -
@VirtualVirgin Can you just hit compile again?