Projects

Ticket #169 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

[HotCocoa] status_item mapping doesn't appear to work

Reported by: chris@… Owned by: rich@…
Priority: minor Milestone:
Component: MacRuby Keywords:
Cc: chris@…, drnicwilliams@…

Description

I'm porting a little single file rubycocoa app to check out hotcocoa but ran into a little problem with the code below:

require 'hotcocoa'                                                        
                                                                          
class Application                                                         
  include HotCocoa                                                        
                                                                          
  def start                                                               
    application :name => "MacMenu" do |app|                               
      app.delegate = self                                                 
      @item = status_item                                                 
      #@item = status_bar.statusItemWithLength NSVariableStatusItemLength 
      @item.title = "MacMenu"                                             
    end                                                                   
  end                                                                     
end                                                                       
                                                                          
Application.new.start                                                     

The @item = status_item call causes the following error:

/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/hotcocoa/mappings/status_item.rb:6:in `alloc_with_options': undefined local variable or method `status_bar' for #<HotCocoa::Mappings::Mapper:0x80039e6e0> (NameError)
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/hotcocoa/mapper.rb:48:in `block in map_method'
	from hotcocoa_menu_test.rb:9:in `block in start'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/hotcocoa/mappings/application.rb:9:in `call'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/hotcocoa/mappings/application.rb:9:in `handle_block'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/hotcocoa/mapper.rb:67:in `block in map_method'
	from hotcocoa_menu_test.rb:7:in `start'
	from hotcocoa_menu_test.rb:16:in `<main>'

Using the commented out line instead everything is fine.

Attachments

status_item.diff Download (473 bytes) - added by isaackearse@… 2 years ago.

Change History

Changed 3 years ago by chris@…

  • cc chris@… added

Cc Me!

Changed 3 years ago by chris@…

Should have mentioned, MacRuby is svn r758

Changed 3 years ago by lsansonetti@…

  • owner changed from lsansonetti@… to rich@…

Rich, can you look at this?

Changed 3 years ago by vincent.isambart@…

The code works if either: * "include HotCocoa" is done not in a class, but at the top level (it's probably why this was not seen earlier). It works because then all the HotCocoa methods become available to all objects * you add "include HotCocoa" in HotCocoa::Mappings::Mapper as alloc_with_options is run on an instance of HotCocoa::Mappings::Mapper

Changed 3 years ago by drnicwilliams@…

  • cc drnicwilliams@… added

Cc Me!

Changed 2 years ago by isaackearse@…

Changed 2 years ago by isaackearse@…

Attached is a diff that fixes the issue for me, but ticket #305 also needs to be applied.

Changed 2 years ago by rich@…

  • status changed from new to closed
  • resolution set to fixed

applied the patch

Note: See TracTickets for help on using tickets.