| <Prev |
■ボタンを極める
基本プロジェクトを作成します。作成方法はひな型プロジェクトを作るを見てください。
buttonとしてプロジェクトを作成しました。
MainMenu.nibのJapaneseのnibファイルを編集します。
ダブルクリックして下さい。

windowを少し小さくしてbuttonを一つ配置します。

名前を付けます。
windowは "wi"

buttonは"bu"
としました。
Event Handlerのclickedにチェックを入れ、AppleScriptのApplication.applescriptにチェックを入れます。

を押してスクリプトを編集します。
STEP1
titleをセットする
http://www.oomori.com/applescript/00000121/00004408.html
を見て下さい。
これがボタンのプロパティです。
いろいろありますね。
まず、タイトルをセットしてみましょう。

|
--step 1 tell button "bu" of window "wi" set title to "タイトル" end tell |
STEP1
titleをセットする
ビルドして実行してみましょう。
ボタンを押すとタイトルが「タイトル」になりましたね。


それでは次にボタンの形状を変更してみましょう
Application.applescriptのスクリプトを全て書き換えます。
ウインドウが開いたときに実行する部分も加わってますので
windowのEventHandler will openにチェックを入れます。


|
-- STEP2 -- Application.applescript global i on will open theObject --開いたときの設定 set i to 4 end will open on clicked theObject -- ボタンの形状を変更する tell window "wi" tell button "bu" if i = 1 then -- 普通のボタン set bezel style to rounded bezel end if if i = 2 then -- 真ん丸 set bezel style to circular bezel end if if i = 3 then -- 四角い画像入り set bezel style to shadowless square bezel end if if i = 4 then -- 角の丸い画像入り set bezel style to regular square bezel set i to 0 end if set i to i + 1 end tell end tell end clicked |

ビルドして実行してみましょう。
ボタンを押す度にボタンの形状が変わります。
STOPで停止します。
--
現在画像はIBでしか入れられないようです。
2002.1.12 (C)Satoshi Oomori