# ’15 -’16 General Discussion for Lesson 5.18

**URL:** <https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839>\
**Category:** Unit and Lesson Discussion\
**Tags:** csp-unit-5, csp-unit-5-lesson-18\
**Created:** [December 7, 2015, 8:14pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839 "2015-12-07T20:14:57Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![dani](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/dani/32/285_2.png) [@dani](https://forum.code.org/u/dani)\
**Post date:** [June 3, 2016, 2:22pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/21 "2016-06-03T14:22:38Z")

</div>

Hi @caroline

I think the easiest way to do this may be a google drawing actually. Its a different type of document in google drive that allows you to create a text box and then you can also create shapes. Then you can layer them to get the look you want.

Best,

Dani

---

<div class="post-metadata">

**Author:** ![caroline](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/caroline/32/196_2.png) [@caroline](https://forum.code.org/u/caroline)\
**Post date:** [June 9, 2016, 4:40pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/22 "2016-06-09T16:40:04Z")

</div>

One of my students wants to display a random image based on a keyword input by the user. Anyone have an easy way to do that?

Note flickr and pencilcode are blocked by my school right now. ☹

---

<div class="post-metadata">

**Author:** ![caroline](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/caroline/32/196_2.png) [@caroline](https://forum.code.org/u/caroline)\
**Post date:** [June 9, 2016, 7:19pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/23 "2016-06-09T19:19:23Z")

</div>

Got Pencilcode unblocked!

var sport = “Sail”  
var sportUrl = “[https://pencilcode.net/img/](https://pencilcode.net/img/)” + sport;  
image(“image1”, sportUrl);  
setPosition(“image1”, 200, 300, 100, 100);

---

<div class="post-metadata">

**Author:** ![gtwrobel](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gtwrobel/32/3576_2.png) [@gtwrobel](https://forum.code.org/u/gtwrobel)\
**Post date:** [June 10, 2016, 9:46pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/24 "2016-06-10T21:46:01Z")

</div>

Excited to hear this works. Very nicely done taking advantage of Pencil Code’s (admittedly awesome) random image feature.

---

<div class="post-metadata">

**Author:** ![caroline](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/caroline/32/196_2.png) [@caroline](https://forum.code.org/u/caroline)\
**Post date:** [June 13, 2016, 4:06pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/25 "2016-06-13T16:06:26Z")

</div>

I have two questions from this student project.

> **[Check out what I made](https://studio.code.org/projects/applab/v9j-NxL1WLbw1dJYrhOFlw/view)**
>
> I wrote the code myself with Code.org

First how do we programmatically change the background color or background image of a button? We tried using setProperty but couldn’t get the syntax to work.

Second, there are a bunch of buttons (81) that are set up to allow you to change the numerical value. Obviously he can’t create an event handler for each button by hand. What is the best way to approach this? Programmatically create the 81 event handlers? Create one event handler for clicking anywhere on the screen and then try to figure out which button the mouse was on?

Thanks!

---

<div class="post-metadata">

**Author:** ![dani](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/dani/32/285_2.png) [@dani](https://forum.code.org/u/dani)\
**Post date:** [June 15, 2016, 2:43pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/26 "2016-06-15T14:43:40Z")

</div>

Hi @caroline!

Changing button backgrounds - I think it would be easier to use an image element instead of a button if you are looking for the background of your button to change. I’m not sure if there is an easy way to change the background of the button itself.

Button of Buttons - @baker created a demo of how you can use the event object to check for clicks on lots of buttons. The demo is here : [https://studio.code.org/projects/applab/\_rkLfFzSwVWYQ1tIQ17wGQ/edit](https://studio.code.org/projects/applab/_rkLfFzSwVWYQ1tIQ17wGQ/edit) . The trick is that the screen always captures click and then you can probe the event object to figure out which button was clicked. That conditional :

if(event.targetId==“screen1”){  
return;  
}

Allows you to ignore the clicks that were on the screen and not on the button.

Hope that helps!

Dani

---

<div class="post-metadata">

**Author:** ![brook](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/brook/32/88_2.png) [@brook](https://forum.code.org/u/brook)\
**Post date:** [December 13, 2016, 2:20am UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839/27 "2016-12-13T02:20:07Z")

</div>



[Previous page](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-18/2839.md?page=1)
