スクリプト例 †
システム音を順番に再生するスクリプト
require 'osx/cocoa' snd_files =`ls /System/Library/Sounds/*.aiff`.split snd_files.each do |path| snd = OSX::NSSound.alloc.initWithContentsOfFile_byReference (path, true) snd.play sleep 0.5 end
InterfaceBuilder で作成した nib ファイル内のクラスと関連づけられたクラス定義のサンプル
class AppController < OSX::NSObject
ib_outlets :monthField, :dayField, :mulField
def awakeFromNib
@monthField.setIntValue Time.now.month
@dayField.setIntValue Time.now.day
convert
end
def convert(sender = nil)
val = @monthField.intValue * @dayField.intValue
@mulField.setIntValue(val)
@monthField.selectText(self)
end
def windowShouldClose(sender = nil)
OSX.NSApp.stop(self)
true
end
end
原著者: 藤本尚邦, <hisa at fobj.com>
Last-modified: 2010-03-25 (木) 03:16:34 (165d)