Sha256: e396c8d84f2a88556d24203db63bd672292a02b44c00f89d56ec426f6793c2dd

Contents?: true

Size: 1.07 KB

Versions: 43

Compression:

Stored size: 1.07 KB

Contents

class UIControlController < UIViewController
  attr :button1
  attr :button2
  attr :touched
  attr :touched_count
  attr :event
  attr :touched_1
  attr :touched_2

  def reset
    @touched = nil
    @touched_count = 0
    @event = nil
    @touched_1 = false
    @touched_2 = false
  end

  def loadView
    super.tap do
      @button1 = UIButton.rounded
      @button1.setTitle('one', forState: UIControlStateNormal)
      @button1.sizeToFit
      @button1.center = self.view.center
      self.view << @button1

      @button2 = UIButton.rounded
      @button2.setTitle('two', forState: UIControlStateNormal)
      @button2.sizeToFit
      @button2.center = [@button1.center.x, @button1.center.y + 30]
      @button1.center = [@button1.center.x, @button1.center.y - 30]
      self.view << @button2

      @button1.on :touch do |sender,event|
        @touched_1 = true
        @touched = sender
        @touched_count += 1
      end

      @button2.on :touch do |sender,event|
        @touched_2 = true
        @touched = sender
        @touched_count += 1
      end

      reset
    end
  end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
sugarcube-1.7.0 app/uicontrol_controller.rb
sugarcube-1.6.3 app/uicontrol_controller.rb
sugarcube-1.6.2 app/uicontrol_controller.rb
sugarcube-1.6.1 app/uicontrol_controller.rb
sugarcube-1.6.0 app/uicontrol_controller.rb
sugarcube-1.5.9 app/uicontrol_controller.rb
sugarcube-1.5.8 app/uicontrol_controller.rb
sugarcube-1.5.7 app/uicontrol_controller.rb
sugarcube-1.5.6 app/uicontrol_controller.rb
sugarcube-1.5.5 app/uicontrol_controller.rb
sugarcube-1.5.4 app/uicontrol_controller.rb
sugarcube-1.5.3 app/uicontrol_controller.rb
sugarcube-1.5.2 app/uicontrol_controller.rb
sugarcube-1.5.1 app/uicontrol_controller.rb
sugarcube-1.5.0 app/uicontrol_controller.rb
sugarcube-1.4.6 app/uicontrol_controller.rb
sugarcube-1.4.5 app/uicontrol_controller.rb
sugarcube-1.4.4 app/uicontrol_controller.rb
sugarcube-1.4.3 app/uicontrol_controller.rb
sugarcube-1.4.2 app/uicontrol_controller.rb