Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Beginning Mac OS® X Tiger™ Dashboard Widget Development Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Fred Terry Beginning Mac OS® X Tiger™ Dashboard Widget Development Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Fred Terry Beginning Mac OS®X Tiger™ Dashboard Widget Development Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-471-77825-7 ISBN-10: 0-471-77825-7 Manufactured in the United States of America 10 1B/SX/QW/QW/IN Library of Congress Cataloging-in-Publication Data: Terry, Fred Beginning Mac OS X Tiger dashboard widget development / Fred Terry p cm Includes index ISBN-13: 978-0-471-77825-7 (paper/website : alk paper) ISBN-10: 0-471-77825-7 (paper/website : alk paper) Mac OS Operating systems (Computers) Macintosh (Computer)—Programming HTML (Document markup language) I Title QA76.76.O63T437 2006 005.4'4682—dc22 2006015521 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other countries, and may not be used without written permission Mac OS and Tiger are trademarks or registered trademarks of Apple Computer, Inc in the US and other countries All other trademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books Simpo PDF About the Author Fred Terry has been involved in the computer industry since making a left-hand turn into it from Ph.D work in medieval languages and literature has written a number of software manuals and articles Merge and Split Unregistered VersionHe - http://www.simpopdf.com and has worked as a systems and network administrator, web developer, programmer, and quality assurance engineer In addition to his ongoing love affairs with AppleScript and Perl, his current programming infatuations are Ruby and Ajax Currently, Fred is a project manager for the Information Management Group at Burns & McDonnell He has a B.A in English from Southwestern Oklahoma State University and an M.A in English from Oklahoma State University He lives in Lawrence, Kansas, with his family and dog Fred can be contacted at pfterry@deadtrees.net For Leesa, who has stood by me through career changes and side projects without losing her patience or humor Acknowledgments No book is produced in a vacuum I want to thank the developers who let me include their widgets for the example chapters in the latter half of the book: Andrew Welch, Nick Rogers, Jesus de Meyer, Jason Yee, and Simon Whitaker I can’t thank Nick Rogers enough for being a racquetball partner, letting me bounce code off of him, and performing the technical edit Cleve Devault needs my thanks for giving me some space to work on this book I also want to thank my agent, Laura Lewin; my acquisitions editor, Katie Mohr; and, most important of all, my development editor, Rosanne Koneval This book wouldn’t have made it over all the hurdles without their capable guidance My thanks to Nick Sayre and Andy Rhoades for allowing me to reprint the “Nick vs Andy” strip (Figure 7-9) Additional “Nick vs Andy” strips can be found at http://nicksayre.com/ As any writer would say, I have to extend my greatest thanks to my family My wife, Leesa; my daughter, Sommer; and my son, Keegan, put up with the constant distraction of this book They are happier than I that it’s finally done Credits Acquisitions Editor Mohr SimpoKatie PDF Merge Graphics and Production Specialists Claudia Bell and Split Unregistered Version - http://www.simpopdf.com Nick Rogers Carrie A Foster Joyce Haughey Barbara Moore Barry Offringa Heather Ryan Alicia B South Copy Editor Quality Control Technician Maarten Reilingh Leeann Harney Editorial Manager Project Coordinator Mary Beth Wakefield Jennifer Theriot Production Manager Proofreading and Indexing Tim Tate Techbooks Development Editor Rosanne Koneval Technical Editor Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B Wikert Contents Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Introduction xiii Part I: An Introduction to Widgets Chapter 1: Tiger, Dashboard, and Widgets OS X Tiger Dashboard and Widgets Managing Dashboard’s Widgets Installing Widgets Installing Local Widgets Downloading and Installing Reloading Widgets What Widgets Are Not Summary Exercises Chapter 2: The Basics of Widgetry What a Widget Is Composed Of HTML, CSS, and JavaScript 9 11 13 13 14 14 15 15 17 HTML CSS JavaScript 18 19 21 Property Lists 23 Widget Properties Creating Property Lists Icons and Images How to Bundle Your Widget Summary Exercises 24 26 30 31 33 33 Contents Chapter 3: Widget Development Environment An Editor and a Browser Simpo TextEdit and Safari PDF Merge and Split BBEdit Unregistered Version - http://www.simpopdf.com Using an Integrated Development Environment Widgetarium Xcode Starting Xcode Building a Plugin Enabling Dashboard Developer Mode Debugging Tools Using Safari as Your Debugger Third-Party Debugging Tools Summary Exercises Chapter 4: Creating a Widget HTML Beginnings Beginning the Project Begin with HTML Adding a Background Creating Widget Structure with CSS Regions Doing the Work with JavaScript Building the Widget Making Sure It Works Summary Exercises Chapter 5: Debugging and Testing First Steps Debugging Tips Syntax and Logic Errors Widget Errors Debugging Tricks Use a Helpful Editor Simplify Log Files Printing Debug Information with Alert Statements vi 35 35 36 38 39 40 41 41 42 47 49 49 50 53 53 55 55 55 57 59 61 63 69 72 75 75 76 77 77 77 78 79 79 79 79 80 81 Contents Using a Debugger Debugging Tools Stepping Through a Widget Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Testing Your Widget Testing Tips Don’t Test Your Own Stuff Break Your Widget Keep a Log What Now? Fixing Bugs Summary Exercises 83 83 83 86 86 86 86 86 87 87 88 88 Part II: Providing User Interaction 89 Chapter 6: Giving a Widget Preferences 91 Adding Preferences to Your Widget How to Show Preferences Creating a Back Side Panel Widget Resources Flipping a Widget The Widget’s HTML File The Widget’s CSS File The Widget’s JavaScript File Testing Your Changes Adding Preferences Adding Preference Selection Saving and Reading Preferences Summary Exercises Chapter 7: Widget Events The Dashboard Activation Event Activation Properties System Resources Removing Widget Preferences Setting Widget Focus Dragging a Widget Control Regions Summary Exercises 91 93 94 95 95 95 97 99 101 102 102 108 111 111 113 113 114 117 119 123 124 125 127 127 vii Contents Chapter 8: Adding to the Widget Interface Resizing Simpo When to Resize the Widget PDF Merge and Split Unregistered How to Resize a Widget 129 Version - http://www.simpopdf.com The HTML File The CSS File The JavaScript File Moving the Close Box Scrolling 132 132 135 136 140 145 146 When to Add Scrolling 146 The HTML File The CSS File The JavaScript File 146 147 148 Summary Exercises Chapter 9: Adding Cut, Copy, and Paste to Your Widget Pasteboard Pasteboard Events Pasteboard Handlers Adding Pasteboard Handlers Summary Exercises Chapter 10: Adding Drag and Drop to the Widget Drag-and-Drop Events Dragging and Dropping from the Finder Using Drag and Drop HTML CSS JavaScript Dragging Between Widgets Summary Exercises Chapter 11: Access Keys Using Access Keys File System Access viii 129 151 151 153 153 153 154 156 157 157 159 160 160 161 162 163 164 166 167 167 169 169 170 Appendix C Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Figure C-2 Submitting to Apple’s Dashboard Downloads Now that you have prepared your widget to upload to widget collections and you have tested the download from your personal website, you are ready to submit the widget to Apple’s Dashboard Downloads The submittal form (www.apple.com/downloads/dashboard/submit/submit.html) is straightforward and asks for contact and product information You’ll need to have a product summary and description for your widget in addition to version information, requirements, size, the download links, and a screenshot Once you click the Submit button, you just have to wait until your widget has been reviewed and is available for everyone to download and begin submitting feature requests 304 Index Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com SYMBOLS AND NUMERICS { } (braces), errors from omitting, 78 # (hash sign) before names in CSS, 62, 163 – (minus sign) in Widgets widget, (period) before names in CSS, 62 + (plus sign) in lower-left portion of screen, " (quotation marks), errors from omitting, 78 3D Clock applet, 190–194 8-bit Unicode Transformation Format (UTF-8), 26, 72 A access keys See also specific keys for Amazon Album Art widget, 230 for command-line access, 171–174 debugging, 78 for Easy Envelopes widget, 180, 203 for file system access, 170–171 for full access, 179–180 for iPhoto Mini widget, 256–257 for iTunes Connection Monitor widget, 268 for Java applet access, 178–179 for More Widgets widget, 279 for network access, 174–176 overview, 169 for QuickTime plugin, 176, 186 for SecureCopy widget, 214 for 3D Clock applet, 191 for Tile Game widget, 170, 171 for Timbuktu Quick Connect widget, 245 for WeatherMaps widget, 174–176 for WebKit and plugin access, 176 for Widget plugin access, 177–179 activating the Dashboard, 113–116 Activity Monitor, 117–119, 194 Index alert() function, 81–83 AllowFileAccessOutsideOfWidget access key for Amazon Album Art widget, 230 for iPhoto Mini widget, 256–257 overview, 24, 170–171 for QuickTime plugin, 186 for SecureCopy widget, 214 for Tile Game widget, 170, 171 AllowFullAccess access key, 24, 179–180, 203 AllowInternetPlugins access key, 25, 176, 186 AllowJava access key, 25, 178–179, 191 AllowMultipleInstances property key, 25 AllowNetworkAccess access key for Amazon Album Art widget, 230 debugging connection problems and, 78 for Easy Envelopes widget, 180 Info.plist file for, 174–175 for More Widgets widget, 279 not required for passing URLs to browser, 176 overview, 25 for SecureCopy widget, 214 for WeatherMaps widget, 174–176 AllowSystem access key for Amazon Album Art widget, 230 asynchronous usage and, 173–174 for command-line access, 171–172 debugging shell command problems and, 78 for iTunes Connection Monitor widget, 268 overview, 25 synchronous usage and, 173 for Timbuktu Quick Connect widget, 245 widget.system() method for, 172, 173–174 Amazon Album Art widget access keys, 230 AppleScripts, 230, 236–237, 238–240 converting JPEG artwork to PICT format, 239–240 CSS file, 230, 231–234 Amazon Album Art widget Simpo Amazon Album Art widget (continued) logos and information on, 92 described, 226 pop-up menus for, 103–108 displaying artwork, 234–236 reading and writing preferences, 108–111 GetSelectionDetails script, 236–237, 238–240 background images See Default.png file PDF Merge and Split Unregistered Version.backgroundImage - http://www.simpopdf.com HTML file, 230–231 style (CSS), 62 Info.plist file, 230 backing up development files, 17 interface, 226–229 BackwardsCompatibleClassLookup property key JavaScript functionality, 231, 234–240 for incorporating applet in a widget, 191 osascript utility used by, 236 for iPhoto Mini widget, 256–257 set of files for, 229 for More Widgets widget, 279 Ambrosia Software overview, 25 Easy Envelopes widget, 177–178, 179–180, 199–210 Bare Bones Software’s TextWrangler text editor, 36 launchSite() function for website, 180 Bart widget, licensing for, 184 answers to exercises, 291–294 BBEdit text editor Apple See also Xcode development environment debugging features of, 79 copyright information for widgets, 18, 19–20, 21 editing hidden files in, 38, 95 Dashboard Downloads site, 299, 301–302, 304 opening files in Library folders with, 38–39 Dashboard Widgets site, 9, 299, 302 saving changes by authenticating, 39 Human Interface Guidelines, 160, 295 syntax coloring by, 26, 27 Installation Guidelines for Developers, 303–304 tuned for website development, 36 mailing lists, 298 Bennet Uk website, 190 OS X developers site, 295 blur() function, 123 programming information online, 295–298 braces ({ }), errors from omitting, 78 tech note on debugging widgets, 78, 296 build() function, 287, 288 AppleClasses folder, 95 building -apple-dashboard-region property, 125–127 SimplePlugin in Xcode, 42–47 AppleScripts WeatherMaps widget, 72–75 for Amazon Album Art widget, 230, 236–237, 238–240 bundles, widget, 31–33 for Timbuktu Quick Connect widget, 245, 251–252 AppleScrollArea.js file, 146, 147 AppleScrollbar.js file, 146, 147 caching, 13 applets See Java applets Calculator widget, 154–155 applications cancelDefault() method, 164 AllowFileAccessOutsideOfWidget key and, 170 canceling bundles for, 33 commands run from widgets, 174 extensions for, 32 dragging and dropping, 164 viewing contents of, 17 canvasDown() function, 205 widgets as, 11 Cascading Style Sheets See CSS widgets versus, 13 case-sensitivity, 30, 78 Aqua Emacs text editor, 36 CFBundleDisplayName property key, arrow icons on Widget Bar left and right sides, 24, 26, 28–29, 30 Automator, CFBundleIdentifier property key, 25, 29 CFBundleName property key, 24, 26, 29, 30 CFBundleShortVersionString property key, 26 back side panel See also preferences for widgets CFBundleVersion property key, 26, 29, 30 adding preference selection, 102–108 changeCategory() function, 280, 286 creating, 93–95 charging for widgets, 303 determining size for, 94 checkboxes in Widgets widget, Done button for hiding, 92, 97, 100–102 checkInput() function, 246, 247 flipping the widget to show, 95–102 class selectors (CSS), 62 info button for showing, 91–92, 97, 99–102 clip variable, 155 C B 306 Simpo PDF clipboardData constant, 153 close box, resizing widgets and location of, 145–146 CloseBoxInsetX property key, 25, 29, 30 CloseBoxInsetY property key, 25, 29, 30 Merge and Split Unregistered Version closing commands run from widgets, 174 widgets, command-line access, 171–174 comments, 19–20 connecting to the Internet, 78, 80, 87 console.log file, 52–53, 80–81, 83 Contents folder in application bundles, 33 control regions, 125–127, 140 converting images to PNG format, 59 JPEG artwork to PICT format, 239–240 copy command, 222 copy functionality See pasteboard copyFrom() function, 220–221 copying adding functionality to WeatherMaps widget, 156–157 files with scp command-line utility, 211–212 widgets to share with other users, widgets to System’s Widget folder, avoiding, copyrights for Apple widgets, 18, 19–20, 21 in CSS files, 19–20 in HTML files, 18, 19 for plugins, 183–184 plugins for protecting, 184–185, 303 for widgets, 185 copyTo() function, 221 cp command, 222 CPU, widget impact on bandwidth, 117–118 creating a widget See also WeatherMaps widget adding CSS, 61–69 adding HTML, 57–61 adding JavaScript, 63, 69–72 beginning the project, 55–57 building, 72–75 listing features desired, 56 testing, 75 CSS (Cascading Style Sheets) See also ID selectors for Amazon Album Art widget, 230, 231–234 for applet incorporation in widget, 193–194 body rule, 62 button placement specified by, 97 class selectors, 62 for control regions, 125–127 copyright information in files, 19–20 declaration, 68–69 tags for regions of styles, 63–65 for dragging and dropping, 163–164 for Easy Envelopes widget, 204–206 for flipping a widget, 97–99 http://www.simpopdf.com for Fortune widget, 18–21 hash sign before names in, 62 hash sign for programmatically changed styles, 163 HTML link to files, 18–19 for iPhoto Mini widget, 260–261 for iTunes Connection Monitor widget, 269–270 mapImage rule, 62 for More Widgets widget, 283–285 period before names in, 62 for pop-up menus, 104–106 positioning text using, 20, 65–69 for Resize widget, 136–139, 142–143 for scrolling, 147–148 for SecureCopy widget, 216–219 selector part, 68 SimplePlugin example, 46–47 testing in Safari, 61 for Timbuktu Quick Connect widget, 249–250 for To Do Tracker widget, 126 for WeatherMaps widget, 61–69, 97–99 widget design provided by, 17 cTempMap() function, 107 cut functionality See pasteboard D Dashboard activation event, 113–116 adding widgets from Widget Bar, cache maintained by, 13 Default.png file for widget interface, 17 described, development mode, 47–48 displaying only widgets used regularly, hiding widgets without removing, installing widgets in, 10 mailing lists, 298 opening with keyboard shortcut, reading and writing preferences, 107–108, 110–111 reference online, 296 reloading widgets in, 13 removing widgets by closing them, removing widgets without installing in, 10, 12 for testing widgets, drawbacks of, 36 tutorial online, 296 websites for, 299 Dashboard Downloads site (Apple), 299, 301–302, 304 307 Index Dashboard Downloads site (Apple) Dashboard Lineup website Simpo Dashboard Lineup website, 299 Widget Bar, Dashboard Widgets website (Apple), 9, 299, 302 widget contents, 15–17 dataTransfer constant, 153 Distorter widget, 178–179, 194 de Meyer, Jesus (widget creator), 183–184, 253, 275 widgets, 301–304 PDF Merge and Split Unregistered Versiondistributing - http://www.simpopdf.com Debug menu (Safari), 49–50, 51 tags debugging See also testing for Amazon Album Art widget, 230–231 Apple tech note on, 78, 296 for control regions, 126 challenges for widgets, 78 for creating regions in widgets, 63–65 code review for, 78–79 for Easy Envelopes widget, 204–206 fixing bugs, 87–88 for front and back of widget, 97 JavaScript Console (Safari) for, 50, 51–53, 77 ID selectors, 63, 64, 97 logging exceptions with Safari, 50, 52–53, 80–81 for incorporating applet in a widget, 193 logic errors, 79 for iPhoto Mini widget, 258, 259–261 overview, 49 for iTunes Connection Monitor widget, 268–269 printing information with alert() function, 81–83 for More Widgets widget, 280–283 Safari Debug menu for, 49–50 for pop-up menus, 104 simplifying widget for, 79 for preference selection, 103 stepping through a widget, 83–85 for QuickTime movie settings, 187 syntax errors, 78 for scrolling, 147 text editor features for, 79 for SecureCopy widget, 214–216 tips and tricks for, 77–83 for tiled widget construction, 135 widget errors, 79 for Timbuktu Quick Connect widget, 246–249, 250 Widgetarium debugger for, 50–51, 83–85 for WeatherMaps widget default map, 123 declaration (CSS), 68–69 division markers See tags Default.png file docopy function, 155, 156 automatically found by Dashboard, 59 Document Object Model (Safari), 297 described, 17, 30 documentation in application bundles, 33 finding image size of, 94 document.getElementById() method for Fortune widget, 19, 30–31 for Dashboard activation, 116 HTML for, 59–60 for pop-up menus, 107–108 required for widgets, 30, 79 in replaceMap() function, 110–111 sizing widget based on dimensions of, 26 for Resize widget, 140–141, 144 for Weather widget, 17, 31, 59 for setting widget focus, 123 WeatherMaps widget background, 59–61, 63 for showing and hiding preferences, 99, 100, 101 Widgetarium for creating, 59 widget.system() method with, 173 deleting See removing docut function, 155 development environment See also Widgetarium; doLoad() function, 115 Xcode development environment Done button BBEdit for, 38–39 CSS for specifying placement, 97, 99 choosing a text editor, 36 drawn and placed by JavaScript, 97, 99 organization features, 35–36 hidePrefs() function for, 100 Safari for testing widgets, 36–37 ID in tag for, 97 Text Edit for, 36 required for back side panel, 92 Dictionary class, 28 testing, 101–102 directories See folders dopaste function, 155 disabling Dashboard development mode, 48 downloading See also Internet resources dismissComboBoxes() function, 124 Dashboard Downloads site, 299, 301–302, 304 displaying or viewing See also hiding; opening Widgetarium, 83 application contents, 17 widgets, and installing, 11–13 preferences, JavaScript for, 99–100 widgets, websites for, 299 scrolling pages of widgets on Widget Bar, dragdrop function, 164–165, 220 308 Simpo PDF dragenter function, 165 dragging and dropping adding the dragover event, 165–166 canceling, 164 Merge and Split Unregistered Version CSS file for, 163–164 drag-and-drop events, 160, 161–162 Dropper widget example, 160–166 event.preventDefault() function for, 164–165 event.stopPropagation() function for, 164–165 feedback for user, 160 from the Finder, 160–161 HTML file for, 162–163 Human Interface Guidelines for, 160, 295 interface extension in OS X, 159 introduction by Apple, 159 JavaScript file for, 164–165 between widgets, 166–167 dragging widgets, 124–125 dragleave function, 165 dragover function, 165–166 drawFrontStuff() function, 207–208 Dropper widget adding the dragover event, 165–166 CSS file, 163–164 HTML file, 162–163 JavaScript file, 164–165 programmatically changed CSS styles in, 164 static CSS styles in, 164 using, 160–161 E Easy Envelopes widget (Ambrosia Software) access keys, 179–180, 180, 203 Ambrosia Software website accessed by, 180 CSS file, 204–206 described, 199 EEWPlugin used by, 177–178, 180, 203 HTML file, 204 Info.plist file, 177, 203–204 interface, 199–203 JavaScript functionality, 177–178, 180, 205, 206–209 EEWPlugin, 177–178, 180, 203 8-bit Unicode Transformation Format (UTF-8), 26, 72 tag for QuickTime plugin, 186 enabling Dashboard development mode, 47–48 debug logging in Safari, 50 JavaScript Console (Safari), 50 Safari Debug menu, 49 erasing See removing errors See debugging etiquette for using plugins, 183–184 event.preventDefault() function, 150, 155, 164–165 http://www.simpopdf.com events See also specific events control regions and, 125–127 for Dashboard activation, 113–116 for drag-and-drop, 160, 161–162 for dragging widgets, 124 pasteboard, 153–154 for removing widget preferences, 119–123 for scrolling, 149–150 for setting widget focus, 123–124 system resources and, 117–119 event.stopPropagation() function, 150, 155, 164–165 exercise answers, 291–294 Extensible Markup Language See XML extensions, 31–32, 43 F filenames, case-sensitivity of, 30 filesystem access keys, 170–171 domains, findAddress() function, 247 findChild() function, 287, 288 Finder dragging and dropping from, 160–161 installing widgets using, 9–10 finding See also Internet resources Default.png image size, 94 Java applets, 190 path to command, 173 plugins on your Mac, 185–186 URLs for items on pages, 57 Flight Tracker widget, 124, 129–130 flip() function, 270, 271 flipping a widget See also back side panel; preferences for widgets CSS file for, 97–99 HTML file for, 95–97 JavaScript file for, 99–101 testing, 101–102 focus() function, 123 focus, setting for widgets, 123–124 folders See also specific folders for developing widgets, 36 filesystem domains for, hiding extensions for, 31 309 Index folders folders (continued) Simpo folders (continued) grabClipboardAddress() function, 177–178 installing widgets by dragging into /Library/Widgets, GraphicConverter tool, 94 opening Library files with BBEdit, 38–39 graphics See converting; PNG organizing development files in, 17 Converter program, 59 PDF Merge and Split Unregistered VersionGraphics - http://www.simpopdf.com for other users, copying widgets to, overriding Library folder contents, for plugins, 185–186 hash sign (#) before names in CSS, 62, 163 for property list files, 23 Height property key, 25, 26 root-level, 4–5 Hello World widget, installing, 9–10 System, avoiding copying widgets into, hidden files, editing in BBEdit, 38, 95 System, minus sign in Widgets widget and, hidden settings, 93 users-level, 4, hidePrefs() function, 100 wdgt extension for names, 31 hiding for widget resources, 95 extensions for folders, 31 for widgets displayed in Widget Bar, preferences, JavaScript for, 100 for widgets installed by you, widgets without removing from Dashboard, for widgets shipped with Tiger, 4–5 HIG (Human Interface Guidelines), 160, 295 Xcode preference settings for, 41 HREF tags (HTML), 69 Font property key, 25 hTempMap() function, 107–108 Fortune widget HTML See also specific tags building a plugin for, 42–47 for Amazon Album Art widget, 230–231 bundling, 31–33 for applet incorporation in widget, 182–183 contents of, 17 calling JavaScript functions from, 96 creating Info.plist file for, 28–30 comments, 19 CSS file, 18–21 copyright information in files, 18, 19 Default.png file, 30–31 for Default.png file, 59–60 HTML file, 18–19, 47 for dragging and dropping, 162–163 JavaScript file, 19, 21–23, 46 dynamic, XMLHttpRequest object for, 296 Free Java website, 190 for Easy Envelopes widget, 204 functions (JavaScript) See also JavaScript; for flipping a widget, 95–97 specific functions for Fortune widget, 18–19, 47 calling from HTML, 96 for iPhoto Mini widget, 257–259 for Done button, 100 for iTunes Connection Monitor widget, 268–269 for info button, 99–100 links to CSS and JavaScript files, 19 for pop-up menus, 107–108 for More Widgets widget, 280–283 for printing debug information, 81–83 opening code in Text Edit, 18 tag for, 71, for QuickTime plugin, 187 72, 147 for Resize widget, 135, 141–142 resizing images as they load, 58–59 for retrieving maps, 57–59 Gandreas Software’s IDE See Widgetarium Safari reference, 297 Gas widget, downloading and installing, 11–13 for scrolling, 146–147 getData method, 155 for SecureCopy widget, 214–216 getDetailsFromiTunes() function, 236–237 syntax coloring for ease of reading, 36 GetSelectionDetails AppleScript, 236–237, 238–240 testing in Safari, 60–61 getside() function, 271 for Timbuktu Quick Connect widget, 246–249 Gmail Checker widget preferences, 93 Unicode format for files, 26 goAmazon() function, 234–235 for WeatherMaps widget, 57–61, 95–97, 103, 123 GoogleMail widget, 188 widget structure provided by, 15 gotoDashboardSite() function, 280 Human Interface Guidelines (HIG), 160, 295 H G 310 Simpo PDF I i icon on widgets, 4, 91, 101 iBook screen space limitations, 129 Merge and Split Version Icon.png file, 17, 30, Unregistered 73–74 ID selectors for buttons used to flip widget, 97 for tags, 63, 64 for dragging and dropping, 163–164 for incorporating applet in a widget, 193 for iPhoto Mini widget, 259, 260 for items to be displayed, 64–65 for More Widgets widget, 283–285 overview, 68 placing images via JavaScript using, 63 for Resize widget, 136–139, 142–143 for scrolling, 147–148 for SecureCopy widget, 216–219 for tiled widget construction, 136–139 for Timbuktu Quick Connect widget, 249–250 using only once per HTML file, 62 for WeatherMaps widget, 62–63, 64–65 IDE (Integrated Development Environment), 39 See also specific IDEs id.rsa file, 222 id.rsa.pub file, 222 images See converting; PNG tag, Default.png file linked by, 19 info button CSS for specifying placement, 97, 99 drawn and placed by JavaScript, 97, 99 i icon for, 4, 91, 101 ID in tag for, 97 required for widget preferences, 92 showPrefs() function for, 99–100 testing, 101–102 Info.plist file See also access keys; property lists access keys available for, 169 AllowFileAccessOutsideOfWidget key usage, 171 AllowInternetPlugins key usage, 176, 186 AllowJava key usage, 178 AllowNetworkAccess key usage, 174–175 AllowSystem key usage, 171–172 for Amazon Album Art widget, 230 configuration information in, 23 for Easy Envelopes widget, 177, 203–204 for Fortune widget, 28–30 for LiveWidget widget, 188–189 for More Widgets widget, 279 Plugin key usage, 177 required for widgets, 32, 79 - for Resize widget, 144–145 for SecureCopy widget, 214 for SimplePlugin, 43, 45–46 syntax errors from omitting access keys, 78 http://www.simpopdf.com for Tile Game widget, 170–171 for Timbuktu Quick Connect widget, 245–246 for Uptime widget, 171–172 for Weather widget, 24 for WeatherMaps widget, 72–73, 174–175 Xcode creation of, 43 installed (hidden) files, editing, 38, 95 installing widgets Apple guidelines for developers, 303–304 automatically, improved security for, 9, 10 changed in Tiger 10.4.2 release, by double-clicking the bundle folder, 33 after downloading, 11–13 by dragging into /Library/Widgets folder, Finder for, 9–10 folder for, removing without installing in Dashboard, 10, 12 Integrated Development Environment (IDE), 39 See also specific IDEs interface of widgets See also back side panel; Default.png file Amazon Album Art widget, 226–229 Dashboard, Default.png file for, 17 Easy Envelopes widget, 199–203 Human Interface Guidelines for, 160, 295 iPhoto Mini widget, 254–255 iTunes Connection Monitor widget, 266–267 More Widgets widget, 275–278 preferences, PNG file for, 17 SecureCopy widget, 212–213 Timbuktu Quick Connect widget, 242–244 Internet resources Apple Installation Guidelines for Developers, 303–304 Apple OS X developers site, 295 Bennet Uk site, 190 Dashboard Downloads site, 299, 301–302, 304 Dashboard Lineup site, 299 Dashboard programming information, 295–296 Dashboard Widgets site, 9, 299, 302 debugging guide, 296 Free Java site, 190 Gmail Checker widget, 93 Human Interface Guidelines, 295 Mac OS X Hints site, 299 MacDevCenter site, 299 MacTech website, 299 mailing lists, 298 311 Index Internet resources Internet resources (continued) Simpo Internet resources (continued) JavaScript See also specific functions maps for WeatherMaps widget, 58 for Amazon Album Art widget, 234–240 QuickTime movie embedding information, 186 buttons drawn and placed by, 97 reference for Dashboard, 296 functions from HTML, 96 PDF Merge and Split Unregistered Version calling - http://www.simpopdf.com Safari information, 297 case-sensitivity of variables, 78 3D Clock applet, 190 debugging with Safari, 49–50, 51–53 tutorial for Dashboard, 296 debugging with Widgetarium, 50–51, 83–85 Universal Binaries Programming Guidelines, 297–298 for dragging and dropping, 164–165 WeatherMaps widget source code, 103 for Easy Envelopes widget, 206–209 WebKit information, 298 for flipping a widget, 99–101 widget distribution sites, 301–302 for Fortune widget, 19, 21–23, 46 Widgetarium site, 83 HTML link to files, 19 XMLHttpRequest object information, 296 for iPhoto Mini widget, 261–264 Zaptastic widget, for iTunes Connection Monitor widget, 270–273 ipAddressAutoComplete() function, 246, 247, 252 limitations of, 184 iPhoto Mini widget logging exceptions with Safari, 50, 52–53 access keys, 256–257 for More Widgets widget, 285–289 Actions menu, 254 placing images using ID selector, 63 Albums menu, 254 pop-up menu functions, 107–108 benefits of, 253 for Resize widget, 140–141, 143–144 CSS file, 260–261 resources in AppleClasses folder, 95 HTML file, 257–259 Safari information online, 297 Info.plist file, 256–257 interface, 254–255 tag for, 71, 72, 147 iPhotoLoader.widgetplugin, 183–184 for scrolling, 148–151 JavaScript functionality, 260, 261–264 for SecureCopy widget, 220–221 set of files for, 255–256 syntax coloring for ease of reading code, 36 iPhoto program, 253 See also iPhoto Mini widget for Timbuktu Quick Connect widget, 250–252 iTunes Connection Monitor widget using plugins with, 184 access keys, 268 for WeatherMaps widget, 69–72, 99–101 CSS file, 269–270 widget functionality provided by, 17 described, 265–266 widget object not available in Safari, 38 free distribution of, 184 JavaScript Console (Safari), 51–53, 77, 80–81 HTML file, 268–269 JPEG images, converting to PICT format, 239–240 Info.plist file, 268 interface, 266–267 JavaScript functionality, 270–273 lastScalarSliderValue variable, 149 set of files for, 267 launchSite() function, 180 whichside preference, 270 launchTB2() function, 246, 247, 250, 252 iTunes music player, 225–226, 236–237, 265 /Library folders, BBEdit for opening files in, 38–39 iTunes Music Store, 225 /Library/Internet Plug-ins folder, 185–186 /Library/Preferences folder, 23 /Library/Widgets folders, 4–6, 8, See also folders live resizing See relative resizing Java applets LiveJournal blog site, 188 access key for, 25, 178–179 LiveWidget widget, 188–190 CSS file for, 193–194 loadAlbums() function, 261–262 HTML file for, 192–193 load_info() function, 272–273 incorporating in widgets, 190–194 loading Info.plist file for, 191–192 calling JavaScript functions during, 96 reloading keyboard shortcuts, 13 L J 312 Simpo PDF N reloading widgets, 13 resizing images during, 58–59 Netopia widgets by invoking Dashboard, 114 Timbuktu Quick Connect widget, 241–252 loadXMLDocument() function, 286–287 Merge and Split Unregistered Version http://www.simpopdf.com Timbuktu screen-sharing program, 241 logging network access, 174–176 alert() function results, 83 nextImage() function, 260 JavaScript exceptions with Safari, 50, 52–53, 80–81, 83 NotePad widget (Widget Machine), 184–185 limitations for debugging, 77 notepad.widgetplugin, 184–185 test results, 86–87 logic errors, debugging, 79 M Mac OS X Hints website, 299 MacBook screen space limitations, 129 MacDevCenter website, 299 MacTech magazine, 298 MacTech website, 299 mailing lists, 298 MainHTML property key, 24, 25, 29 Marcel Bresink Software-Systeme’s TinkerTool, 49 memory applet use of, 194 widget impact on, 118 Meyers, Stephan (widget creator), minimize() function, 206–207 minus sign (–) in Widgets widget, monitoring widgets, 117–119 Monkey Business Labs’ To Do Tracker widget, 125–126, 166 More Widgets widget access key, 279 CSS file, 283–285 described, 275 HTML file, 280–283 Images folder, 283 Info.plist file, 279 interface, 275–278 JavaScript functionality, 280, 285–289 set of files for, 278–279 widget.setPreferenceForKey() method, 286 mouseDown() function for iPhoto Mini widget, 262–263 for Resize widget, 140, 143 for scrolling, 149 mouseMove() function for iPhoto Mini widget, 263, 264 for Resize widget, 140, 143–144 for scrolling, 149 mouseUp() function for iPhoto Mini widget, 262, 263–264 for Resize widget, 141, 144 for scrolling, 149–150 MyPluginClass.m file, 46–47 O Objective C language, 183 onbeforecopy event, 153–154 onbeforecut event, 153–154 onbeforepaste event, 153–154 onChange script for pop-up menus, 107 oncopy event, 153–154 oncut event, 153–154, 156 ondrag event, 161–162 ondragend event, 161–162 ondragenter event, 162, 166 ondragleave event, 162, 166 ondragover event, 162, 166 ondragstart event, 161–162 ondragstart() function, 124 ondrag.start handler, 124 ondrag.stop handler, 124 ondrop event, 162, 164 onhide() function for Dashboard activation, 115, 116 onHide() function (WeatherMaps widget), 121 online resources See Internet resources onload=’setup();’ for calling JavaScript functions, 96 onpaste event, 153–154 onRemove() function adding to WeatherMaps widget, 121–123 in Weather widget, 119–121 onremove() function (iTunes Connection Monitor), 270–271 onshow() function for Dashboard activation, 115, 116 for iTunes Connection Monitor widget, 270 onShow() function (WeatherMaps), 121, 123 openInApp() function, 262 opening See also displaying or viewing; enabling AllowFileAccessOutsideOfWidget key and, 170 closing widgets without, Dashboard with keyboard shortcut, files in Library folders with BBEdit, 38–39 HTML code in Text Edit, 18 JavaScript Console (Safari), 51 313 Index opening opening (continued) Simpo opening (continued) logic errors from forgetting to call, 79 Safari from Widgets widget, Objective C language for, 183 Widget Installer without Safari, 13 QuickTime, 186–188 Widgets widget, example, 42–47 PDF Merge and Split Unregistered Version SimplePlugin - http://www.simpopdf.com Xcode for the first time, 41–42 uses for, 184–185 OS X Tiger plus sign (+) in lower-left portion of screen, Apple developers site, 295 PNG (Portable Network Graphics) See also specific files automatic widget installation security changes, 9, 10 converting other formats to, 59 cat names for earlier versions, for icons of widgets, 17, 30 evolution of, for preferences interface of widgets, 17, 95 filesystem domains, use by widgets, 15 Human Interface Guidelines, 160, 295 for user interface of widgets, 17, 30 Mac OS X Hints site, 299 for Weather widget, 17 new features, pop-up menus widget suite shipped with, 4–5 CSS for, 104–106 osascript utility, 236, 245 tags for, 104 oTempMap() function, 107 JavaScript functions for, 107–108 outputString property, 172–173 onChange script for, 107 for preference selection, 103–108 tags for, 103 posting widgets, 303–304 package contents, viewing, 16–17 PowerBooks, 4, 129 parameters, debugging and, 79 preferences for widgets parseXMLDocument() function, 287–288 adding preference selection to widget, 102–108 PasswordPlugin, 189–190 creating back side panel for, 93–95 passwords flipping the widget for, 95–102 for LiveWidget widget, 189–190 hidden settings for, 93 for scp command-line utility, 212 i icon for, 4, 91, 101 for SecureCopy widget, eliminating, 221–223 JavaScript for showing and hiding, 99–100 paste functionality See pasteboard JavaScript needed for, 17 pasteboard need for, 91, 93 adding handlers to WeatherMaps widget, 156–157 overview, 91–93 Calculator widget implementation, 154–155 PNG files for, 17 constants, 153 pop-up menus for, 103–108 events, 153–154 reading and writing, 108–111 handlers, 154–155 removing, 119–123 period (.) before names in CSS, 62 resources for, 95 PICT format, converting JPEG images to, 239–240 setting, 4, 91–92 PID number, 80 writing, access key and, 171 Plugin access key preferences for Xcode, 41–42 for Easy Envelopes widget, 177–178 prevImage() function, 260 for Fortune widget, 29, 30 printing debug information using alert() function, overview, 25 81–83 for SimplePlugin example, 45, 46 private key for SecureCopy widget, 221–223 plugins processDownloadedImage() function, 237–240 access key for, 25, 176 processXMLRequest() function, 286, 287 for copyright protection, 184–185, 303 projects, beginning, 55–57 defined, 183 Property List Editor, 26, 27, 28–30 errors from failing to include, 79 property lists See also access keys; Info.plist file etiquette for using, 183–184 creating, 26–30 incorporating in widgets, 188–190 defined, 23 LiveWidget widget example, 188–190 Dictionary class for root element, 28 P 314 Simpo PDF editing, 26 errors from omitting required keys, 79 folder for files, 23 Info.plist file for, 23 Merge and Split Unregistered Version property keys in (table), 24–26 text editors for, 26 XML header for files, 26–27 public key for SecureCopy widget, 221–223 Q QuickTime plugin, 176, 186–188 quotation marks ("), errors from omitting, 78 R - resizing close box location and, 145–146 CSS file for, 136–139, 142–143 determining need for, 132 http://www.simpopdf.com dynamic information and, 130–131 HTML file for, 135, 141–142 images as they load, HTML for, 58–59 images in Widgetarium, 59 JavaScript file for, 140–141, 143–144 keeping image proportions when, 59 making widgets resizable, 132–146 single panel for, 132, 141–145 thumb control for, 132, 133, 135, 140–141 tiled construction for, 132–141 widget examples illustrating, 129–131 resource description framework (RDF), 275 restoreUserLogin() function, 190 revisions See versions of widgets Rich Site Summary (RSS), 275 See also RSS feeds Rogers, Nick (widget creator), 241 rollie, 91 RSS feeds, 146, 275 See also More Widgets widget radar maps See WeatherMaps widget radMap() function, 82, 107 RDF (resource description framework), 275 refreshing widgets, 113–116 relative resizing close box location and, 145–146 CSS file for, 136–139, 142–143 determining need for, 132 HTML file for, 135, 141–142 JavaScript file for, 140–141, 143–144 making widgets resizable, 132–146 single panel for, 132, 141–145 thumb control for, 132, 133, 135, 140–141 ways of providing, 132–134 reloading widgets or keyboard shortcuts, 13 removing See also hiding disabling Dashboard development mode, 48 preferences for widgets, 119–123 uninstalling widgets, widgets from Dashboard, widgets without installing in Dashboard, 10, 12 replaceMap() function getting stored preferences, 110–111 HTML file for, 70–71 JavaScript code for, 69–70, 71–72, 110–111 tag for, 71, 72 Resize widget CSS file, 136–139, 142–143 tags for tiled construction, 135 HTML file, 135, 141–142 Info.plist file, 144–145 JavaScript file, 140–141, 143–144 link to thumb control image, 135 using single background panel, 141–145 using tiled construction, 132–141 S Safari cache maintained by, 13 as debugger, 49–50, 51–53 Document Object Model overview, 297 interaction with Widget Installer, 11 JavaScript widget object not available in, 38 online resources, 297 opened by Widgets widget More Widgets button, opening Widget Installer without, 13 reloading pages in, 13 testing CSS in, 61 testing HTML in, 60–61 testing widgets in, 36–37 widget download confirmation by, 11 widget preferences access not supported by, 95 saveUserLogin() function, 189 scalarSlider selectors, 148 scalarSlider variable, 148, 149 scp command-line utility, 211–212, 220–221 See also SecureCopy widget scp.css file, 216–219 scp.html file, 214–216 scp.js file, 214 tag, 71, 72, 147 315 Index tag scrolling Simpo scrolling frameworks for, 43 CSS file for, 147–148 linked to widget through Info.plist file, 45–46 determining need for, 146 SimplePlugin folder, 42 HTML file for, 146–147 text editor, 36 PDF Merge and Split Unregistered VersionskEdit - http://www.simpopdf.com JavaScript file for, 148–151 Ski Report widget, 83–85 pages of widgets on Widget Bar, slideClosed() function, 235 resources in AppleClasses folder, 95, 146 slideClosedCompleted() function, 236 tracking slider changes, 150–151 slideIt() function, 235–236 searching() function, 271 slideOpen() function, 235 secure shell (SSH) suite, 211 slider resources in AppleClasses folder, 95 SecureCopy widget sliderChanged() function, 150–151 access keys, 214 slogin command-line utility, 211 CSS file, 216–219 Sort menu (Widgets widget), eliminating need for password, 221–223 sorting widgets in Widgets widget, HTML file, 214–216 spelling errors, 78, 99 Info.plist file, 214 Spotlight, interface, 212–213 ssh command-line utility, 211 JavaScript functionality, 220–221 SSH (secure shell) suite, 211 scp command-line utility overview, 211–212 ssh-keygen -t rsa command, 222 set of files for, 213 startTB2Connection() function, 246, 250–252 using with public and private keys, 221–223 Stocks widget, 80, 87, 92, 130, 131 widget.system() method used by, 212, 220–221 stopping commands run from widgets, 174 security sWeatherMap() function, 108, 110 for automatic widget installation, 9, 10 syntax coloring, 26, 27, 36, 79 for getData method, 155 syntax errors, debugging, 78 for transferring files, 211 sys-keygen command, 221–222 tags for preference selection, 103 System filesystem domain, 6, selectors See ID selectors system resources, 114, 117–119 setAlbumArt() function, 231 setCloseBoxOffset() method, 145–146 setData method, 155 temperature maps See WeatherMaps widget setup() function Terminal application, 211–212, 221–222 for Resize widget, 141 testing See also debugging for scrolling, 150 allowing feature requests from testers, 87 for SecureCopy widget, 220 beta testers for, 86–87 for WeatherMaps widget, 175 Dashboard drawbacks for, 36 for WeatherMaps widget copy command, 156, 157 design problems discovered by, 87 sharing fixing bugs, 87–88 music over a network with iTunes, 265 flipping a widget, 101–102 plugins, etiquette for, 183–184 HTML file in Safari, 60–61 Timbuktu screen-sharing program, 241 logging results, 86–87 widgets with other users on your Mac, Safari for, 36–37 showAddressFontPanel() function, 208, 209 trying to break your widget, 75, 86 showDetails() function, 289 using different machines for, 75 showing See displaying or viewing; hiding WeatherMaps widget, 75, 101–102 showPageSetup() function, 205, 208–209 widget actions not supported by Safari, 95 showPrefs() function, 99–100 by yourself, limitations of, 86 showReturnAddressFontPanel() function, 208, 209 Text Edit, opening HTML code in, 18 SimplePlugin example text editors See also specific editors building in Xcode, 42–47 choosing, 36 CSS file, 46–47 debugging features of, 79 T 316 Simpo PDF syntax coloring by, 26, 27, 36, 79 with Unicode or UTF-8 capabilities, 26 XML-specific, 26 TextWrangler text editor (Bare Bones Software), 36 Merge and Split Unregistered Version 3D Clock applet, 190–194 Tiger See OS X Tiger Tile Game widget, 170–171 tiled widget construction See Resize widget Timbuktu Quick Connect widget (Netopia) access keys, 245 AppleScript, 245, 251–252 CSS file, 249–250 described, 241 HTML file, 246–249 Info.plist file, 245–246 interface, 242–244 JavaScript functionality, 246, 247, 250–252 osascript utility used by, 245 set of files for, 244–245 Timbuktu screen-sharing program (Netopia), 241 TinkerTool (Marcel Bresink Software-Systeme), 49 To Do Tracker widget (Monkey Business Labs), 125–126, 166 toggleBarcodes() function, 180 toggleSlide() function, 231, 235 trashing See removing U Unicode format for property lists, 26 uninstalling widgets, Universal Binaries Programming Guidelines, 297–298 updating widgets, 113–116 uptime() function, 172 Uptime utility, 172 Uptime widget, 171–173 URLs finding for items on pages, 57 widget.openURL() method for, 174–176 User filesystem domain, UTF-8 (8-bit Unicode Transformation Format), 26, 72 V validating data entry, 87 version.plist file, 73 versions of widgets formal numbers versus build numbers, 26 multiple, Dashboard limitations for testing, 36 property keys for numbers, 26 version.plist file for documenting, 73 Victor, Bret (widget creator), 184 viewing See displaying or viewing; hiding W - wdgt extension for folder names, 31 Weather widget http://www.simpopdf.com contents of, 15–17 Default.png file, 31 Info.plist file, 24 preferences, 91–92 preferences cleared by, 119–121 weatherLogo() function, 126 WeatherMaps widget access keys, 174–176 activating the Dashboard, 116 adding links to other maps, 63–69 alert() function in, for debugging, 81–83 beginning the project, 55–57 building the widget, 72–75 control regions, 126–127 copy command for, 156–157 CSS for, 61–63, 65–69, 97–99 cTempMap() function, 107 default map, 123 Default.png file, 59–61, 63 tags for creating page regions, 63–65 features list, 56 finding the URLs for maps, 57 flipping, 95–102 hTempMap() function, 107–108 HTML for background image, 59–61 HTML for default map, 123 HTML for flipping, 95–97 HTML for preference selection, 103 HTML for retrieving maps, 57–59 HTML incorporating CSS, 62–63 Icon.png file, 73–74 ID selectors for maps, 64–65 Info.plist file, 72–73, 174–175 JavaScript for, 69–72, 99–101 network access, 174–176 oTempMap() function, 107 pasteboard handlers for, 156–157 placing the map on the background image, 63 pop-up menus for preferences, 103–108 preference selection for, 102–108 preferences needed for, 91 radMap() function, 82, 107 reading and writing preferences, 107–111 removing preferences, 121–123 replaceMap() function, 69–72, 110–111 resizing maps as they load, 58–59 setup() function, 175 size of maps and design issues, 56–57 source code online for, 103 317 Index WeatherMaps widget WeatherMaps widget (continued) Simpo WeatherMaps widget (continued) More Widgets widget use of, 286 sWeatherMap() function, 108, 110 for pop-up menus, 107–108 testing, 75, 101–102 in replaceMap() function, 110 URLs possibly changed for, 102 widget.system() method PDF Merge and Split Unregistered Version for - http://www.simpopdf.com version.plist file, 73 AllowSystem access key, 172 Web resources See Internet resources asynchronous usage, 173–174 WebKit SecureCopy widget use of, 212, 220–221 access key for, 25, 176 synchronous usage, 173 default behavior with ondrop event, 164 Width property key, 25, 26 findChild() function, 287, 288 Wikipedia widget, 166, 167 information online, 298 Wimic widget, 80 plugins on your Mac, 186 window.onblur handler, 123 XMLHttpRequest object, 286, 296 window.onfocus handler, 123, 124 Welch, Andrew (widget creator), 199 window.resizeTo() method, 141, 144 Whitaker, Simon (widget creator), 226 Widget Bar Icon.png file for, 30 Xcode development environment (Apple) using, 4–5, 7–8 building a plugin, 42–47 Widget Installer, 10, 11, 13, 33 directory preferences for build files, 41 See also installing widgets extension for projects, 43 Widget Machine’s NotePad widget, 184–185 frameworks, 43 Widgetarium (Gandreas Software) as granddaddy of OS X IDEs, 39 creating Default.png file in, 59 Info.plist file creation by, 43 debugger, 50–51, 83–85 installing widget from, 9–10 overview, 40, 83 keeping widget copies in, 10 saving images in PNG format, 59 overview, 41 website, 83 Property List Editor with, 26, 27, 28–30 widget-com.argon18.widget.itcm.plist file, 270 saving project window states when closing, 41–42 widget.onhide property, 114–116, 121 starting for the first time, 41–42 widget.onreceiverrequest property, 115 warning for files saved with earlier version, 42 widget.onremove property, 115, 121 widgets included with, 9, 17 widget.onshow property, 114–116, 121 XML (Extensible Markup Language) widget.openURL() method, 176 dynamic, XMLHttpRequest object for, 296 widget.preferenceForKey() method feeds, 93 AllowFileAccessOutsideOfWidget function and, 171 for property lists, 23, 26–27 in onshow() function, 116 resources in AppleClasses folder, 95 in replaceMap() function, 110–111 XMLHttpRequest object (WebKit), 286, 296 for writing preferences, 108 Widget/Resources folder, 95, 146 Widgets widget determining widgets you installed, Yee, Jason (widget creator), 184, 265 Icon.png file for, 30 overview, 8–9 resizing example, 130, 131 uninstalling widgets, Zaptastic widget, obtaining, widget.setPreferenceForKey() method AllowFileAccessOutsideOfWidget function and, 171 LiveWidget widget use of, 189 X Y Z 318 [...]... bottom of Dashboard In the Widget Bar you can see all of the widgets that are installed on your Macintosh in the root-level /Library/Widgets/ folder and your users-level /Library/Widgets/ folder The 14 widgets that ship 4 Simpo PDF Tiger, Dashboard, and Widgets with Tiger are installed in the /Library/Widgets/ folder at the root level of your hard disk and everyone who has an account on your Macintosh can... you know that the widget has been added (Figure 1-4) If you want to remove a widget from Dashboard, click the Close box in the upper-left corner of the widget that you want to remove, and the widget disappears into the Close box You can close a widget without opening the widget by holding down the Option key whenever you move your cursor over it This displays the Close box for the widget Figure 1-4... you get stuck while doing the exercises The following is a summary of the topics covered in each chapter: xiv ❑ Chapter 1, Tiger, Dashboard, and Widgets,” introduces you to Dashboard widgets and explains how they are an integral part of Tiger ❑ Chapter 2, “The Basics of Widgetry,” explains the different parts of a widget The chapter shows how widgets are constructed by examining the HTML, Cascading... earlier, Appendix A contains the answers to all of the chapter exercises WebKit information is covered throughout the book Appendix B contains pointers to additional sources of Dashboard programming information on the Web What You Need to Use This Book Dashboard is part of the Macintosh OS X 10.4, or Tiger, release To follow the examples in this book, you must have Tiger installed on your Macintosh You may... Managing Dashboard s Widgets Simpo In the Tiger 10.4.2 release, Apple introduced the Widgets widget The Widgets widget provides a compact interface managing widgets (Figure 1-5) You open the Widgets widget by clicking the Manage PDF Merge for and Split Unregistered Version - http://www.simpopdf.com Widgets button after you have opened the Widget Bar Widgets provides you with a scrolling list of the widgets... network database Widgets can also run any Unix command or AppleScript on OS X Having instant access to all of your information and OS X services is what really makes the Dashboard metaphor work You can even see it reflected in the Dashboard icon; each widget represents one gauge on your Dashboard Whom This Book Is For This book is for anyone who wants to create Dashboard widgets or modify existing ones... appear next to these widgets 8 Tiger, Dashboard, and Widgets Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Figure 1-6 Clicking the More Widgets button at the bottom of the Widgets widget launches Safari, if it isn’t already running, and takes you to Apple’s Dashboard Widgets website (http://www.apple.com/downloads/ dashboard/ ) Installing Widgets So how do you get additional widgets... files of the widgets supplied with Tiger ❑ Chapter 3, Widget Development Environment,” introduces the different development environment options available In addition to the Xcode development environment supplied with Tiger, you look at using text editors and browsers as your development environment Third-party development and debugging tools are also introduced ❑ Chapter 4, “Creating a Widget, ” details... are adding widgets to Dashboard One way to manage your widgets, for instance, is to uncheck all of the widgets that you want to keep installed, but don’t use very often The widgets that you use regularly but don’t add to Dashboard are in the Widget Bar, ready for you to add quickly If you want to remove or uninstall a widget, you click the red minus sign next to its name in the Widgets widget Dashboard. .. of each example is a detailed explanation of the example in the “How It Works” section The examples in the book help you gain an understanding of the elements and construction of Dashboard widgets When possible, the concepts that you learn in one example are incorporated into another widget example so you can see how they are related to each other within a widget Rather than build one large widget with .. .Beginning Mac OS X Tiger Dashboard Widget Development Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Fred Terry Beginning Mac OS X Tiger Dashboard Widget Development. .. Introduction xiii Part I: An Introduction to Widgets Chapter 1: Tiger, Dashboard, and Widgets OS X Tiger Dashboard and Widgets Managing Dashboard s Widgets Installing Widgets Installing Local Widgets... 10.4.2 systems CloseBoxInsetX Number Optional Specifies the offset for the location of the widget close box on the x- axis Positive values move the close box toward the right of the widget The number