← App Builder apps

Draw how you showed it

Add a drawing to the values journal: a Drawing object on the Describe screen, its picture kept in a variable when you click Add, and an Image on the Journal screen that shows it. Find out why the order of two actions matters, and what the journal still can't do.

Some things are easier to draw than to say. Apps let you draw, take photos and record sounds; each makes a picture or sound the app can keep and show somewhere else.

The values journal from the last lesson keeps what you wrote. Today it also keeps a drawing of what you did.

  1. Describe: a space to draw in, under the typing box.
  2. Journal: the drawing you just made, under the list.

A drawing is something the app makes while it runs, like a photo or a recording. The app keeps it as a picture, and a variable can hold it, just as a variable holds a number or some text.

How this lesson works: See it, Build, Check, Make it yours
See itTry the finished thing first, so you know what you are building.

Try the finished app

Pick a value, type what you did, then draw it in the box with the mouse (or your finger). Click Add to my journal. The drawing shows on the Journal screen.

Watch LastDrawing under the variables on the left. When you click Add, it changes from "" to something like media:7f3a09c2: that's the app's name for the picture it kept.

Try it yourselfYour edits are saved in this browser.

BuildWatch the short clip, then do the steps. Your app carries on from the step before.

Build 1: a space to draw

  1. Open the Describe screen. We've moved Add to my journal down to make room.
  2. Click + Add object, then Drawing. It's called Drawing1: rename it Drawing (double-click its name in the sidebar, or its ⋯ menu, Rename).
  3. In Properties, place it under the typing box: x 229, y 184, width 342, height 280 (or drag it there).
  4. On the Events tab, add an action to On start of screen: Drawing, Clear Drawing.
  5. Run it from Choose and draw something. Go back to Choose and pick again: the page is clean.
A Drawing object · Sound on for the voiceover
Try it yourselfYour edits are saved in this browser.

The Describe screen has a Drawing, and it's cleared each time the screen starts.

    Run your program. This ticks when your code does all of the above.

    BuildWatch the short clip, then do the steps. Your app carries on from the step before.

    Build 2: keep the drawing

    1. In the sidebar, under the variables, add a variable called LastDrawing. Leave its starting value empty.
    2. On the Describe screen, add an action to AddButton is clicked: Variables, Set variable LastDrawing to Drawing.picture
    3. Run it, draw, and click Add. Watch LastDrawing change on the left.

    Drawing.picture is the drawing as a picture. The app keeps it and gives it a name such as media:7f3a09c2, so the variable holds that name, not all the dots of the drawing.

    Try it yourselfYour edits are saved in this browser.

    A variable LastDrawing, and Add sets it to Drawing.picture (and still adds the entry and goes to Journal).

      Run your program. This ticks when your code does all of the above.

      BuildWatch the short clip, then do the steps. Your app carries on from the step before.

      Build 3: show it on the Journal

      1. Open the Journal screen. We've made the list shorter to make room.
      2. + Add object, Image. Rename it LastImage, and place it under the list: x 335, y 335, width 130, height 130.
      3. On the Events tab, add an action to On start of screen: LastImage, Set LastImage picture to the one in, value LastDrawing
      4. Run it from Choose: pick, type, draw, Add. Your drawing is on the Journal.

      There are two "set picture" actions. Set picture to picks one of the app's pictures while you design it. Set picture to the one in works it out while the app runs, from a variable or Drawing.picture.

      Show a picture the app made · Sound on for the voiceover
      Try it yourselfYour edits are saved in this browser.

      The Journal screen has an Image called LastImage, and when the screen starts it shows the picture in LastDrawing.

        Run your program. This ticks when your code does all of the above.

        CheckA quick check that the idea has stuck.

        Check: order and what's kept

        Nib wanted each entry to start with a clean page, so Nib put Clear in the Add event.

        The journal keeps every entry you write. Does it keep every drawing?

        Nib's Journal shows the error "There is no picture yet", even though Nib drew something. Click the line where Nib first goes wrong.

        You add a Kindness entry with a heart drawing, then a Courage entry with a star. What does the Journal screen show?

        Make it yoursChange your app on purpose, then try it on someone.

        Make it yours: Clear and Undo

        Add a Button ClearButton (text Clear) under the drawing, moving Add down a little, and an event: ClearButton is clicked → Clear Drawing.

        Add UndoButton (text Undo) beside it: UndoButton is clicked → Undo the last line on Drawing.

        Want more? Set pen colour on Describe's start, with a different colour for each value (an If on Chosen).

        Try it yourselfYour edits are saved in this browser.

        A ClearButton on Describe clears the Drawing.

          Run your program. This ticks when your code does all of the above.

          An UndoButton on Describe takes back the last line.

            Run your program. This ticks when your code does all of the above.

            Now you can
            Next lesson7. Show it's done: photosGive the chores checklist a photo for each chore: tick a chore, then take a photo or choose one, and it appears beside that chore. A variable remembers which chore was ticked, and the photo event checks it.
            For teachers

            Students add drawing to the values journal: a Drawing object on Describe (cleared when the screen starts), Drawing.picture kept in a variable when Add is clicked, and an Image on the Journal screen that shows it with Set picture to the one in. They find out that action order matters (Nib clears the page before keeping it) and that one variable keeps only the latest drawing, which sets up tables in Data apps. About 45 minutes.

            Open the teacher guide: answers, solutions, slides and a worksheet.

            Students will be able to

            Before class

            This lesson starts from the finished values journal with room made for a drawing (Add moved down on Describe, the list shorter on Journal). Students who missed the journal lesson can still do it: the first step has them use the finished app.

            A drawing is made while the app runs. Drawing.picture turns it into a picture the app keeps in the browser (on this device, nothing is sent) and names it, such as media:7f3a09c2. Variables, lists and tables hold that name. Drawings, not photos, so there are no faces.

            If a student clicks Add without drawing anything, the Journal says "There is no picture yet". That's honest: there's nothing to show. An If (LastDrawing is not "") is a fine extra for a quick student.

            The second check question is the set-up for Data apps › A journal with drawings, where a table keeps a drawing with every entry.

            Handing in: drawings are made while the app runs, so a Share link carries the app but not the student's entries. To hand in entries with their drawings, students use Save and include what the app kept (a .zip).

            Running the lesson

            1. Try it: ask students to watch LastDrawing on the left as they click Add. What does media:… mean?
            2. Build 3: checkpoint: does the drawing show on the Journal? If it says there's no picture, did they draw before Add?
            3. Check: take a vote on the two-entries question before anyone tries it.

            The hard part (on purpose)

            The two picture actions look alike. Set picture to picks a picture while you design; Set picture to the one in works one out while the app runs. If students pick the first, the list of choices has no drawing in it: that's the clue.

            When students get stuck

            Stretch and support

            Stretch: Set the pen colour by value on Describe's start: an If on Chosen, with a colour for each value (Set pen colour of Drawing to "red").

            Support: Do Build 1 together on the board; pairs do Builds 2 and 3.

            Where it leads

            Next: Show it's done: photos, the same idea with a Photo, a picture per chore. In Data apps, A journal with drawings keeps a drawing with every entry, in a table.

            What each step is for