Class: HotCocoa::PopUpItemList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hotcocoa/mappings/appkit/popup.rb

Direct Known Subclasses

PopUpMenuItemList

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(control) ⇒ PopUpItemList

Returns a new instance of PopUpItemList.



7
8
9
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 7

def initialize control
  @control = control
end

Instance Attribute Details

#controlObject (readonly)

Returns the value of attribute control.



5
6
7
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 5

def control
  @control
end

Instance Method Details

#<<(title) ⇒ Object



11
12
13
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 11

def << title
  control.addItemWithTitle title
end

#[](index) ⇒ Object



15
16
17
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 15

def [] index
  control.itemTitleAtIndex index
end

#delete(title) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 19

def delete title
  if title.kind_of? Fixnum
    control.removeItemAtIndex title
  else
    control.removeItemWithTitle title
  end
end

#each(&block) ⇒ Object



51
52
53
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 51

def each &block
  control.itemTitles.each &block
end

#insert(title, at: index) ⇒ Object



27
28
29
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 27

def insert title, at: index
  control.insertItemWithTitle title, atIndex: index
end

#selectedObject



31
32
33
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 31

def selected
  control.titleOfSelectedItem
end

#selected=(title) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 35

def selected= title
  if title.kind_of? Fixnum
    control.selectItemAtIndex title
  else
    control.selectItemWithTitle title
  end
end

#selected_indexObject



43
44
45
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 43

def selected_index
  control.indexOfSelectedItem
end

#sizeObject



47
48
49
# File 'lib/hotcocoa/mappings/appkit/popup.rb', line 47

def size
  control.numberOfItems
end