Class: Shoes::Swt::SwtButton

Inherits:
Object
  • Object
show all
Includes:
Common::UpdatePosition, Common::Focus, Common::Remove, Common::Visibility
Defined in:
shoes-swt/lib/shoes/swt/swt_button.rb

Direct Known Subclasses

Button, CheckButton

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Remove

#remove

Methods included from Common::Focus

#focus, #focused?

Constructor Details

#initialize(dsl, app, type) {|@real| ... } ⇒ SwtButton

Returns a new instance of SwtButton

Yields:


14
15
16
17
18
19
20
21
22
23
24
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 14

def initialize(dsl, app, type)
  @dsl = dsl
  @app = app

  @type = type
  @real = ::Swt::Widgets::Button.new(@app.real, @type)

  yield(@real) if block_given?

  set_size
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app


12
13
14
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 12

def app
  @app
end

#dslObject (readonly)

Returns the value of attribute dsl


12
13
14
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 12

def dsl
  @dsl
end

#realObject (readonly)

Returns the value of attribute real


12
13
14
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 12

def real
  @real
end

Instance Method Details

#click(blk) ⇒ Object


30
31
32
33
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 30

def click(blk)
  remove_listeners
  @real.addSelectionListener { eval_block blk }
end

#enabled(value) ⇒ Object


42
43
44
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 42

def enabled(value)
  @real.enable_widget value
end

#eval_block(blk) ⇒ Object


26
27
28
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 26

def eval_block(blk)
  blk.call @dsl
end

#remove_listenersObject


35
36
37
38
39
40
# File 'shoes-swt/lib/shoes/swt/swt_button.rb', line 35

def remove_listeners
  listener_array = @real.getListeners ::Swt::SWT::Selection
  listener_array.each do |listener|
    @real.removeListener ::Swt::SWT::Selection, listener
  end
end