четверг, 19 ноября 2009 г.

Section 4: Creating a button to run the code

http://www.google.com/google-d-s/scripts/bracket_maker.html#section4

In this section we show how to create a button and attach a script to that button.

  1. Select the second sheet (ie the "Bracket" sheet) and go to "Insert-->Drawing..." in your menus.
  2. The "Insert Drawing" dialogbox should pop up. Use the "Insert shape" icon to insert a new shape. I chose a beveled rectangle.
  3. Double click on the shape you just inserted and type "Create Bracket".
  4. Format your shape if you want and then close the dialogbox when finished. You should see your shape inserted on your sheet. You may want to move it to a location right below column G. This is what my sheet looks like now:



  5. Now click on the shape and notice that under the "Drawing" menus, there is an option to "Assign macro...". Click on "Assign macro..." and type "createBracket", which is the name of the main function in our script. Now your button will run the "createMacro" function each time it is clicked on. Note that to edit the shape, you can shift click or control click on the shape.



Комментариев нет:

Отправить комментарий