Class: Opine::Native::Application::OSXApplication

Inherits:
Cocoa::NSObject
  • Object
show all
Defined in:
lib/opine/widgets/application_osx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



5
6
7
# File 'lib/opine/widgets/application_osx.rb', line 5

def application
  @application
end

#blockObject

Returns the value of attribute block.



5
6
7
# File 'lib/opine/widgets/application_osx.rb', line 5

def block
  @block
end

Instance Method Details

#applicationDidFinishLaunching(notification) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/opine/widgets/application_osx.rb', line 7

def applicationDidFinishLaunching notification
  menubar = NSMenu.new.autorelease
  app_menu_item = NSMenuItem.new.autorelease
  menubar.addItem app_menu_item
  application.setMainMenu menubar

  app_menu = NSMenu.new.autorelease
  quit_menu_item = NSMenuItem.alloc.initWithTitle("Quit",
    action: :terminate,
    keyEquivalent: 'q'
  ).autorelease
  app_menu.addItem quit_menu_item
  app_menu_item.setSubmenu app_menu

  application.activateIgnoringOtherApps true

  block.call if block
end