- 追加された行はこの色です。
- 削除された行はこの色です。
*目次 [#r683ab6e]
#contents
*Dashcodeとは [#k6fd33ea]
http://ja.wikipedia.org/wiki/Dashcode
*ユーザガイド [#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
**ラベル文字のかえ方 [#sf8dbd6d]
document.getElementById("YourTextId").innerText = "New Value";
**開発指針 [#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]
**スクロールエリア [#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]
**スライダー[#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]
**アニメーション[#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]
**ボタン[#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
***書き方 HTML [#r07e6fae]
<script type='text/javascript' src='/System/Library/WidgetResources/AppleClasses/AppleButton.js' charset='utf-8'/>
***設定画面表示や保存や復元について[#mef2dd0e]
昔のバージョンでは上記のコードを下記のようにかくんだってさ
<script type='text/javascript' src='AppleClasses/AppleButton.js' charset='utf-8'/>
***ボタンIDと初期化メソッド名を記入する方法 [#r0047727]
<body onload="setup();">
...
<div id="myButton"></div>
...
</body>
***CSSで座標を決めます。 [#u3273cc1]
#myButton {
position: absolute;
right: 20px;
bottom: 20px;
}
***初期化用のJavascript基本文 [#l7d4a07c]
AppleButton(
buttonElement,
label,
height,
leftImage,
leftImageDown,
leftImageWidth,
middleImage,
middleImageDown,
rightImage,
rightImageDown,
rightImageWidth,
onclick
);
***初期化用のJavascript例 [#e41e30b4]
var gMyButton;
function setup()
{
gMyButton = new AppleButton(
document.getElementById("myButton"),
"Click Me",
23,
"button/buttonLeft.png",
"button/buttonLeftDown.png",
11,
"button/buttonMiddle.png",
"button/buttonMiddleDown.png",
"button/buttonRight.png",
"button/buttonRightDown.png",
11,
buttonClicked);
}
***AppleButton オブジェクトのプロパティやメソッド [#pb15140e]
-クリック
gMyButton.onclick
-画像について
gMyButton.setDisabledImages( leftImageDisabled, middleImageDisabled, rightImageDisabled)
-有効/無効
gMyButton.enabled
-有効/無効設定
gMyButton.setEnabled(boolean)
-ボタン削除
gMyButton.remove()
-ラベルのテキスト要素
gMyButton.textElement
**設定画面表示や保存や復元について[#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]
**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"
例:"cd ~;"
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
);
}
}
***自作のコマンド結果をテキストエリアに貼付ける例 [#nf61989d]
function myonclick(event)
{
var output = widget.system("/bin/ls -l -a", null).outputString;
//alert(output);
document.getElementById("textarea").innerText = output;
}
***コマンダー [#ufa10ae3]
画面にコマンド用のテキストを貼付け、出力用のテキストエリアを貼付けて
それぞれ、下記のコードにあうように名前をつけた例です。
function doCommand(event)
{
var inputField = document.getElementById("cmdInput");
var outputArea = document.getElementById("cmdOutput");
var cmd = widget.system("cd ~;" + inputField.value, null);
outputArea.value = cmd.outputString;
}
“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]
**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
そのまま保存しても下記のようなエラーに見舞われる
TypeError: Result of expression 'widget.system' [undefined] is not a function.
開発環境では動作するのに、理由がわからない。
そのご、試してみると、最初からサンプル道理に入力すると、うまく行くが、
どこかの手順を間違えると復活できないようだ。
間違えたら、プロジェクトを入れ替えるしかないのかどうかは、よくわからない。
*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/
**Widgetをつかっていろいろ実験しているサイト [#p66a4583]
http://www.ie.u-ryukyu.ac.jp/~e035740/nakamurasoba/40/index.html
**アップル - Mac OS X - Dashboard [#e089e3a9]
http://www.apple.com/jp/macosx/features/dashboard/
**アップル - Dashboard ウィジェット(ウィジェット ダウンロード) [#r153ce9a]
http://www.apple.com/jp/downloads/dashboard/
**Apple - Dashboard Widgets(ウィジェット ダウンロード) [#w2fe57ed]
http://www.apple.com/downloads/macosx/dashboard/
*Dashboard ウィジェット 紹介サイト [#bdc9441f]
http://www.dashboardwidgets.com/
http://www.dstation.net/
http://dpsmac.com/category/dashboard/
http://www.dashboard.jp/
http://www.geocities.jp/widget_mania/
・類似・関連ソフト
Yahoo! Widgets(旧 Konfabulator)
ttp://widgets.yahoo.com/
Adobe Apollo(Flash や WebKit を用いたデスクトップアプリ環境)
ttp://labs.adobe.com/technologies/apollo/
Amnesty Widget Browser(Panther でも Dashboard)
ttp://amnesty.mesadynamics.com/WidgetBrowser.html
・Mac Dashboard wiki(Dashboard の情報を共有/過去ログ等)
http://www2.atwiki.jp/macstar/