*目次 [#r683ab6e] #contents *ユーザガイド [#e7b195c9] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashcode_UserGuide/Contents/Resources/en.lproj/Introduction/Introduction.html *リファレンス [#ibd3b158] http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/Dashboard_Ref/DashboardRef/DashboardRef.html%23//apple_ref/doc/uid/TP40001339 下記のことが記載されています。 **ハローワールドと、最小限のプロジェクト構成、XML定義の記述例 [#r456a53f] “Widget Basics” introduces the Dashboard environment and describes how to develop a simple widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/WidgetBasics.html%23//apple_ref/doc/uid/TP40008117-SW2 **開発指針 [#fc00bd80] “Designing Widgets” provides guidelines and tips for designing successful widgets. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Design.html%23//apple_ref/doc/uid/TP40003053-SW3 **AppleClassと呼ばれる標準部品について [#d91ccb50] “Introduction to the Apple Classes” discusses the Apple Classes, what they offer, and how to include them in your widget. スクロールエリアとか、ボタンとかの話で下記に細かく記載されているので下記参照 http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AppleClasses.html%23//apple_ref/doc/uid/TP40003186-SW1 ***スクロールエリア [#u975735a] “Using Scroll Areas” talks about integrating a scroll area into your widget. 極力使わないようにという http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AppleScrollArea.html%23//apple_ref/doc/uid/TP40003241-SW2 ***スライダー[#d79534ee] “Using an Apple Slider” tells you how to use a slider control in your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AppleSlider.html%23//apple_ref/doc/uid/TP40003242-SW2 ***アニメーション[#q58d1a41] “Using Animation” discusses using the animation-focused Apple Classes. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AppleAnimator.html%23//apple_ref/doc/uid/TP40003187-SW1 ***ボタン[#c0a7c53d] “Using an Apple Button” talks about using the AppleButton class to build your own buttons, and how to use the AppleGlassButton subclass for standard-style buttons. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AppleButton.html%23//apple_ref/doc/uid/TP40003185-SW5 ***設定画面表示や保存や復元について[#mef2dd0e] “Widget Backs and Preferences” tells you how to display, save, and retrieve preferences. AppleInfoButton, used on a widget's front to signify that a widget has a back. When clicked, it flips the widget over. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Preferences.html%23//apple_ref/doc/uid/TP40003043-SW3 ***2台マック持ってたときに、同期するメカニズムがあるらしいので、その説明っぽい。[#q8597d1b] “Syncing Widgets” looks at the Dashboard Sync feature in Mac OS X v.10.5 and how you can handle syncing in your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/SyncingWidgets.html%23//apple_ref/doc/uid/TP40004748-SW1 **マウスクリックなどイベントの使い方 [#w788f4de] “Using Widget Events” discusses Dashboard and widget events that your widget may want to be aware of. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Events.html%23//apple_ref/doc/uid/TP40003044-SW1 **部品の領域の宣言方法 [#t4dde62c] “Declaring Control Regions” defines and explains how to work with control regions, areas where controls are present in a widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/ControlRegions.html%23//apple_ref/doc/uid/TP40003045-SW3 **リサイズ方法 [#lbd6d9ef] “Resizing Widgets” provides code useful for implementing resizing in your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Resizing.html%23//apple_ref/doc/uid/TP40003046-SW1 **キャンバスの使い方 [#k4d29865] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Canvas.html%23//apple_ref/doc/uid/30001236-BAJGJJAH Using the Canvas talks about using the Canvas feature of WebKit within your widget. **カットアンドペースト [#b0f28e06] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/CopyAndPaste.html%23//apple_ref/doc/uid/30001234-BAJGJJAH Using the Pasteboard from JavaScript talks about supporting copy, cut, and paste in a widget. **ドラック アンド ドロップ [#f03220e3] Using Drag and Drop From JavaScript tells you about the handlers needed to support drag and drop in your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/DragAndDrop.html%23//apple_ref/doc/uid/30001233-BAJGJJAH **国際化 [#ra233d96] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Localization.html%23//apple_ref/doc/uid/TP40003047-SW2 “Localizing Widgets” discusses offering your widget with international users in mind, using localizable strings and other resources. [#y77fd738] **アクセスキー(機能をつかうかどうか)の指定方法 [#d08d9db6] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/AccessKeys.html%23//apple_ref/doc/uid/TP40003048-SW2 “Specifying Access Keys” describes the widget access keys, used to turn on resource access for your widget. **外部リソースにアクセス [#vdc6ba3d] http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/ExternalAccess.html%23//apple_ref/doc/uid/TP40003049-SW1 “Accessing External Resources” talks about opening applications or web pages in a browser with your widget. **コマンドラインツールにアクセス [#d26370f8] これをやるまえに、アクセスキーでコマンドラインを使えるようにするかどうか設定が必要 AllowSystemってのがBoolean型であるからそれをなんとかするらしいんだけど、 Dashcoadの設定画面で設定するところあったよ。えーっと、開発エディタ画面の左の真ん中あたりに、「ウィジェットの属性」ってのがあるとおもう。 それをクリックして、「コマンドラインアクセスを許可」にチェックをいれときゃなんとかなるんじゃないかな。 *** widget.system() [#daecb224] パラメータは2つあって、1つ目は、フルパスのコマンドとその引数 例:"/bin/ls -l -a" 2つめはハンドラで、同期、非同期の切り替えに使うらしく引数をもたせなきゃならないみたいだ。 例:systemHandler これをnullにすると、同期モードになるっぽい ***標準出力や、標準エラーや、コマンド結果を得る書き方 [#p364c21d] 標準出力 var output = widget.system("id -un", null).outputString; 標準エラー var error = widget.system("id -un", null).errorString; コマンド状態 var status = widget.system("id -un", null).status; ***非同期の書き方 [#z3ce598f] var myCommand = widget.system("/sbin/ping foo.bar", endHandler); myCommand.onreadoutput = outputHandler; または、下記の書き方 widget.system("/sbin/ping foo.bar", endHandler).onreadoutput = outputHandler; で、ハンドラーは引数を絶対とるようにします。 function outputHandler(currentStringOnStdout){ // Code that does something with the command’s current output like... document.getElementById("element").innerText = currentStringOnStdout;} ***キャンセルの方法 [#nf11344b] myCommand.cancel(); ***標準入力があるような場合の入力方法 [#k92e4021] myCommand.write("8*5"); ***コマンドを終了する場合 [#c1451cbf] myCommand.close(); ***サンプルコード リソースを後から使うプロセスが優先して使う例[#r6864f02] 下記のサイトからダウンロードできるコードを見ていきましょう。 http://developer.apple.com/library/safari/#samplecode/Voices/Introduction/Intro.html%23//apple_ref/doc/uid/DTS10003699 上記のプログラムが起動すると、下記のコードが実行されます。 function setup() { if(window.widget) { currentlyBeingSpoken = widget.system("/usr/bin/osascript -e 'say \"Welcome to Voices!\" using \"Fred\"'" , doneSpeaking); } } コマンドが終わったら、doneSpeakingと定義した関数が呼ばれます。 しゃべり終わればcurrentlyBeingSpokenにはnull がはいります。 ***サンプルコード リソースを後から使うプロセスが優先して使う例[#kba8e37c] 上記のサンプルのつづきです。ユーザが入力するフェーズです。 if(window.widget) { if(currentlyBeingSpoken != null) { currentlyBeingSpoken.cancel(); } currentlyBeingSpoken = widget.system("/usr/bin/osascript -e 'say \"" + textToSpeak + "\" using \"" + chosenVoice + "\"'" , done); } しゃべっているかどうか、かぶらないようにしているのがわかります。かぶりそうになると、キャンセルをしています。 ***サンプルコード イベントを受けて、画面で設定されているパラメータをよみとって実行する例[#bcfe4e33] 音声を切り替えるとしゃべる箇所です。 function voiceChanged(elem) { var chosenVoice = elem.options[elem.selectedIndex].value; document.getElementById("voiceMenuText").innerText = chosenVoice; if(window.widget) { if(currentlyBeingSpoken != null) { currentlyBeingSpoken.cancel(); done(); } currentlyBeingSpoken = widget.system( "/usr/bin/osascript -e 'say \"Hi, I`m " + chosenVoice + ".\" using \"" + chosenVoice + "\"'" , doneSpeaking ); } } “Accessing Command Line Utilities” tells you how to access command-line utilities and scripts from within your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/CommandLine.html%23//apple_ref/doc/uid/TP40003050-SW1 **プラグインの作り方 [#lc9927ad] “Creating a Widget Plug-in” discusses native code plug-ins that your widget uses to interact with other applications. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/WidgetPlugin.html%23//apple_ref/doc/uid/TP40003051-SW1 ***全てのプラグインが実装しなくてはならないコード [#rfd38fe9] - (id) initWithWebView:(WebView*)webview ***例 [#qd2d58c1] - (void) windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject - (void) windowScriptObjectAvailable:(WebScriptObject *) windowScriptObject { [windowScriptObject setValue:self forKey:@"MyWindowScriptObject"]; ... } ***WebScriptObjectオブジェクトをプラグインから受け取る例 [#o8268017] <html> <head> ... <script> ... function someFunction() { ... if (MyWindowScriptObject) { MyWindowScriptObject.someMethod(someArg); } ... } ... </script> </head> ... </html> ***XCodeの標準的なプロパティ管理ファイル [#k75375e7] Info.plistをあつかうファイルで NSPrincipalClass が担当しているようです。 ***ロード後に処理を走らせる方法 [#te76ab5e] <html> ... <body onload='MyWindowScriptObject.someMethod(someArg)'> ... </body> </html> *Objective-Cを呼び出す方法 [#r26b25ee] Using Objective-C From JavaScript provides more detail on bridging Objective-C and JavaScript. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/ObjCFromJavaScript.html%23//apple_ref/doc/uid/30001215-BBCBFJCD **作品のパッケージ方法 [#kf870acb] “Delivering Widgets” tells you about packaging and distributing your widget. http://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/Delivery.html%23//apple_ref/doc/uid/TP40003052-SW1 *Dashcode のwiki [#e0d16f77] http://f16.aaa.livedoor.jp/~pseuho/Newt/pukiwiki.php/?Dashboard%2FDashboard%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0%A5%AC%A5%A4%A5%C9 *Dashcodeでプログラミング(ネットワーク上のファイルにアクセスする) [#j3666ce2] http://uchyax.exblog.jp/5443700/ *デバッカの使い方 [#y9aac338] http://uchyax.exblog.jp/5359765/ http://uchyax.exblog.jp/5375242/ *Dashboard Station [#f78c2c0f] いろいろダウンロードできる http://www.dstation.net/modules/mydownloads/