Class: Shoes::Swt::InputBox

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

Overview

Class is used by edit_box and edit_line

Direct Known Subclasses

EditBox, EditLine

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, text_options) ⇒ InputBox

Returns a new instance of InputBox.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 17

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

  @real = ::Swt::Widgets::Text.new(@app.real, text_options)
  @real.set_size dsl.element_width, dsl.element_height
  @real.set_text dsl.style[:text]
  @real.add_modify_listener do |event|
    @dsl.call_change_listeners unless nothing_changed?(event)
  end

  @real.add_verify_listener do |event|
    event.doit = false if @readonly
  end
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



14
15
16
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 14

def app
  @app
end

#dslObject (readonly)

Returns the value of attribute dsl.



14
15
16
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 14

def dsl
  @dsl
end

#readonly=(value) ⇒ Object (writeonly)

Sets the attribute readonly

Parameters:

  • value

    the value to set the attribute readonly to.



15
16
17
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 15

def readonly=(value)
  @readonly = value
end

#realObject (readonly)

Returns the value of attribute real.



14
15
16
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 14

def real
  @real
end

Instance Method Details

#caret_to(index) ⇒ Object



50
51
52
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 50

def caret_to(index)
  @real.set_selection(index)
end

#enabled(value) ⇒ Object



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

def enabled(value)
  @real.enabled = value
end

#highlight_text(start_index, final_index) ⇒ Object



46
47
48
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 46

def highlight_text(start_index, final_index)
  @real.set_selection(start_index, final_index)
end

#textObject



33
34
35
# File 'shoes-swt/lib/shoes/swt/input_box.rb', line 33

def text
  @real.text
end

#text=(value) ⇒ Object



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

def text=(value)
  @last_text = @real.text
  @real.text = value
end