property ca : current application
on run
set BK to ca's NSBackingStoreBuffered
tell ca's NSWindow's alloc()
initWithContentRect_styleMask_backing_defer_({{300, 300}, {200, 100}}, 3, BK, false)'s autorelease()
setTitle_("NSSoundTest")
set wind to it
end tell
tell current application's NSButton's alloc()
tell initWithFrame_({{0, 0}, {90, 24}})
setTitle_(" Play ")
setTarget_(me)
setBezelStyle_(1)
setAction_("Play:")
set button to it
setTranslatesAutoresizingMaskIntoConstraints_(false)
end tell
end tell
set conview to wind's contentView
conview's addSubview_(button)
set xx to current application's NSLayoutAttributeCenterX
set yy to current application's NSLayoutAttributeCenterY
set xx_con to current application's NSLayoutConstraint's constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant_(conview, xx, ca's NSLayoutRelationEqual, button, xx, 1, 0)'s autorelease()
set yy_con to current application's NSLayoutConstraint's constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant_(conview, yy, ca's NSLayoutRelationEqual, button, yy, 1, 0)'s autorelease()
conview's addConstraint_(xx_con)
conview's addConstraint_(yy_con)
wind's makeKeyAndOrderFront_(me)
end run
on Play_(sender)
ca's NSSound's soundNamed_("Submarine")'s play()
end Play_