Revision: 445 http://trac.macosforge.org/projects/ruby/changeset/445 Author: rich@infoether.com Date: 2008-08-14 21:42:06 -0700 (Thu, 14 Aug 2008) Log Message: ----------- make the generated app a little more robust and demo how to use the menus. the menu file now does not target not action Modified Paths: -------------- MacRuby/trunk/data/hotcocoa_template/lib/application.rb MacRuby/trunk/data/hotcocoa_template/lib/menu.rb Modified: MacRuby/trunk/data/hotcocoa_template/lib/application.rb =================================================================== --- MacRuby/trunk/data/hotcocoa_template/lib/application.rb 2008-08-14 21:50:47 UTC (rev 444) +++ MacRuby/trunk/data/hotcocoa_template/lib/application.rb 2008-08-15 04:42:06 UTC (rev 445) @@ -1,12 +1,44 @@ require 'hotcocoa' -include HotCocoa - # Replace the following code with your own hotcocoa code -application :name => "__APPLICATION_NAME__" do |app| - window :frame => [100, 100, 500, 500], :title => "__APPLICATION_NAME__" do |win| - win << label(:text => "Hello from HotCocoa", :layout => {:start => false}) - win.will_close { exit } +class Application + + include HotCocoa + + def start + application :name => "__APPLICATION_NAME__" do |app| + app.delegate = self + window :frame => [100, 100, 500, 500], :title => "__APPLICATION_NAME__" do |win| + win << label(:text => "Hello from HotCocoa", :layout => {:start => false}) + win.will_close { exit } + end + end end -end \ No newline at end of file + + # file/open + def on_open(menu) + end + + # file/new + def on_new(menu) + end + + # help menu item + def on_help(menu) + end + + # This is commented out, so the minimize menu item is disabled + #def on_minimize(menu) + #end + + # window/zoom + def on_zoom(menu) + end + + # window/bring_all_to_front + def on_bring_all_to_front(menu) + end +end + +Application.new.start \ No newline at end of file Modified: MacRuby/trunk/data/hotcocoa_template/lib/menu.rb =================================================================== --- MacRuby/trunk/data/hotcocoa_template/lib/menu.rb 2008-08-14 21:50:47 UTC (rev 444) +++ MacRuby/trunk/data/hotcocoa_template/lib/menu.rb 2008-08-15 04:42:06 UTC (rev 445) @@ -1,18 +1,18 @@ module HotCocoa - def application_menu(app) + def application_menu menu do |main| main.submenu :apple do |apple| - apple.item :about, :title => "About #{app.name}", :target => app, :action => "orderFrontStandardAboutPanel:" + apple.item :about, :title => "About #{NSApp.name}" apple.separator apple.item :preferences, :key => "," apple.separator apple.submenu :services apple.separator - apple.item :hide, :title => "Hide #{app.name}", :key => "h", :target => app, :action => "hide:" - apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt], :target => app, :action => "hideOtherApplications:" - apple.item :show_all, :title => "Show All", :target => app, :action => "unhideAllApplications:" + apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h" + apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt] + apple.item :show_all, :title => "Show All" apple.separator - apple.item :quit, :title => "Quit #{app.name}", :key => "q", :target => app, :action => "terminate:" + apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q" end main.submenu :file do |file| file.item :new, :key => "n" @@ -25,7 +25,7 @@ win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o" end main.submenu :help do |help| - help.item :help, :title => "#{app.name} Help" + help.item :help, :title => "#{NSApp.name} Help" end end end
participants (1)
-
source_changes@macosforge.org