sugarcube 0.20.12 → 0.20.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ class UIControl
7
7
  # @example
8
8
  # button = UIButton.alloc.initWithFrame([0, 0, 10, 10])
9
9
  # button.on(:touch) { my_code }
10
- # button.on(:touchupoutside, :touchcancel) { my_code }
10
+ # button.on(:touch_up_outside, :touch_cancel) { my_code }
11
11
  # # up to two arguments can be passed in
12
12
  # button.on(:touch) { |sender,touch_event| my_code }
13
13
  def on(*events, &block)
@@ -29,7 +29,7 @@ class UIControl
29
29
  #
30
30
  # @example
31
31
  # button.off(:touch)
32
- # button.off(:touchupoutside, :touchcancel)
32
+ # button.off(:touch_up_outside, :touch_cancel)
33
33
  # button.off # all events
34
34
  def off(*events)
35
35
  if events.length == 0
@@ -47,6 +47,20 @@ class UIControl
47
47
  self
48
48
  end
49
49
 
50
+ # Useful during testing, or to simulate a button press.
51
+ #
52
+ # @example
53
+ # button.trigger(:touch)
54
+ # button.trigger(:touch_drag_outside, :touch_drag_exits)
55
+ def trigger(*events)
56
+ event_mask = 0
57
+ events.each do |event|
58
+ event = event.uicontrolevent unless event.is_a? Fixnum
59
+ event_mask |= event
60
+ end
61
+ sendActionsForControlEvents(event_mask)
62
+ end
63
+
50
64
  # private
51
65
  # event blocks need to be retained, and the addTarget method explicitly does
52
66
  # *not* retain `target`. This makes sure that callbacks are retained by
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.20.12'
2
+ Version = '0.20.13'
3
3
  end
@@ -226,7 +226,7 @@ class NSAttributedString
226
226
  end
227
227
 
228
228
  def +(attributedstring)
229
- NSMutableAttributedString.alloc.initWithAttributedString(self) + attributedstring
229
+ NSMutableAttributedString.alloc.initWithAttributedString(self) + attributedstring.nsattributedstring
230
230
  end
231
231
 
232
232
  end
@@ -17,6 +17,13 @@ describe 'UIControl' do
17
17
  controller.touched_count.should == 1
18
18
  end
19
19
 
20
+ it 'button1 should respond to touches using `trigger`' do
21
+ controller.button1.trigger(:touch)
22
+ controller.touched.should == controller.button1
23
+ controller.touched_1.should == true
24
+ controller.touched_count.should == 1
25
+ end
26
+
20
27
  it 'button2 should respond to touches' do
21
28
  controller.button2.sendActionsForControlEvents(:touch.uicontrolevent)
22
29
  controller.touched.should == controller.button2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.12
4
+ version: 0.20.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: