Unit 4 app project - button won't work


On this student’s Help screen the right hand house is a button which is supposed to take you to settings screen. The same code works on his other page, but not on the Help screen. (Only the 4 bottom pages work currently.)
Any help you can give will be appreciated!
Thanks,
Dina Picou

Dina,

Interesting problem - what I am noticing is that there are a lot of error messages based on “id’s that don’t exist”. Was this coded in blocks or text? If in text the student might have misspelled a key word or two (very common). If in block then would be using the drop down.

From the first screen I can click on the “help” button but then I get all the error messages - I think the first step is cleaning up all of those (making sure those id’s exist) and then continuing to troubleshoot. What is curious is the id that doesn’t show up as “missing” is “settings1” which is attached to the “home” button your student labeled. So I would fix (or comment out) all the other id’s and isolate that button to make sure it works.

Hope that gets you started on figuring it out,
Brad

Thanks for looking at it. He is still having the issue. He created a console log to check that it is reading the “click” and it is, but won’t go to the settings or home page, only from the Help page. I put in some comments to show the two events that don’t seem to work, and we don’t know why? Here is a link to the project: https://studio.code.org/projects/applab/9lFS5XE5rUCSaPb0N47DzdcipdAgZgu-2ItLnTcet0E

Thanks for any help you can give?
Dina

Dina,

Still a little confused about what needs to happen (it’s a pretty solid app) but the student doesn’t need all of the different buttons, the if statements can all be in the same button selection:

onEvent(“return”, “change”, function(event) {
if (getText(“return”) == “Home”) {
console.log("Selected option: " + getText(“return”));
setScreen(“Home”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Library”) {
console.log("Selected option: " + getText(“return”));
setScreen(“Library”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “New Profile”) {
console.log("Selected option: " + getText(“return”));
setScreen(“New_Profile”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Search”) {
console.log("Selected option: " + getText(“return”));
setScreen(“Search_Profile”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Problems Checklist”) {
console.log("Selected option: " + getText(“return”));
setScreen(“PC”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Solutions possible”) {
console.log("Selected option: " + getText(“return”));
setScreen(“SP”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Buy parts”) {
console.log("Selected option: " + getText(“return”));
setScreen(“Buy_Parts”);
setText(“return”, “Stay”);
}
if (getText(“return”) == “Help”) {
console.log("Selected option: " + getText(“return”));
setScreen(“Help”);
setText(“return”, “Stay”);
}
});

I also only had it write to the console log inside of the if statement when true - otherwise all of the console logs will write.

Try that and let me know if it helps!
Brad

Hi Dina,

The problem is that the entire background of the help screen is also being used for an event on line 4 that changes the screen back to the help screen. When the user clicks on the gear, the program has two events triggered. The first changes the screen to the settings page, and the second changes the screen to the help page. It happens so fast that you can’t see the change to the settings page. A similar thing is happening with the house. If you put a console log statement in the event that starts on line 4, you will see that it’s also being triggered when those elements are clicked.

A big problem that’s making this hard to debug is that the student used a series of similar id’s for all of these elements. The student should consider having more meaningful names rather than “help”, “help1”, “help2”. Maybe something like a prefix that tells you the screen, then the name of the button/element (“helpBackground”, “settingsHelpButton”, “homeHelpButton”).

Regards,
Elizabeth