![protopie accordian protopie accordian](http://gamho365.com/work/BERBRICK.png)
Any item hiding itself broadcasts the message REORDER along with its id and ALL components underneath (e.g., with an id greater than that of the hiding component) move upwards by 84 pixels. If it does not match, it hides itself, even if it’s already hidden. If it matches, it resets itself (position AND opacity), even if it is already visible and in its original position. Hide, Reset and Reorder happen on every keystrokeĮach time a letter is typed into the search box, EVERY component decides if it matches the search, with no memory of whether it matched previously.
#Protopie accordian free#
Feel free to skip ahead if all of the above makes sense. If you’re still a little cloudy on why this is working, let’s recap the logic. Your search should be fully working! Why does this work? This will be all we need to do! return to the main scene and preview. In the bottom drop down, choose the hiding_id variable.
![protopie accordian protopie accordian](http://gamho365.com/work/GIVENCHY.png)
In the first drop down, choose the variable id. Add a condition under the Receive Response.This is why we needed to use sequential numbering when we gave each song a value for id. If the receiver’s id is GREATER than the sender’s id (i.e., id > hiding_id), then we’ll move the receiver’s position upwards one slot. In the Receive, each copy will compare its OWN id to hiding_id. We’ve also sent along the id of the component that originally sent the message and assigned that value to a variable named hiding_id. All other components reorder yourselves accordingly.”Īt this point ALL copies of the Song component will receive that message INCLUDING the copy that sent it. I don’t match the search, so I am hiding. If components could talk, this particular copy of the Song component would be telling ALL of the other copies “I’m id: x. We’ve used a Send Response in our “NO MATCH” condition to broadcast the message REORDER. By doing this, we ensure that all of our components receive the lower case version of whatever we typed in the search box.īefore we continue it’s important to point out what will happen. In the box under “Send Value Together” modify the existing formula to use the lowerCase() function as follows: lowerCase('Search field'.Still, in the main scene, let’s modify our Send Response under the Detect Trigger. For example, lowerCase("ProtoPie is the BEST!!") will give us protopie is the best!!. As the name suggests, it converts text to lower case. ProtoPie includes another built-in function we can use called lowerCase(). Our approach will be to convert BOTH our search keyword AND the song title to lower case before we execute the indexOf() function. To solve this, we need to remove case sensitivity from the equation. However we would have a poor experience if we settled for this behavior. As far as it is concerned, C is not the same thing as c. When using the indexOf() function, case matters. Let’s fix this! Part 3: Make the Search Case Insensitive Leave = (equals) selected as the operator, and enter the value -1 in the bottom box.Use the following formula: indexOf('Title'.text, searchKeyword) and click OK.In our condition, we’re going to check for the first possibility - no match.Still, in the master copy of the Song component, add a condition under the Receive Trigger.If the function gives us anything other than -1 then this song matches our search and should be included in the results.If the function gives us the value -1 this means the song doesn’t match our search, and therefore should be excluded from the search results.When we execute indexOf(), it gives us back a number indicating the position of the found text, or -1 if no match is found. This will be the value we passed into the variable searchValue. searchValue is the keyword you’re looking for within source.source is the text you want to search through.It works with two parameters: source and searchValue. indexOf() looks through some text to see if some other text is present in it. We’re going to use ProtoPie’s built-in indexOf() function in our condition. Now we’d like to determine if the keyword matches any part of the song title. We’ve set up our Song component to receive the search keyword from the scene. Part 2: Displaying Results in the Search Box That’s what we’re doing here when we choose Assign to Variable. ? Whenever your Pie receives a message that has a value supplied along with it, you need to assign that value to a variable first before you can work with it.