Class: Shoes::InputBox

Inherits:
Common::UIElement show all
Includes:
Common::Changeable, Common::Focus, Common::State
Defined in:
shoes-core/lib/shoes/input_box.rb

Direct Known Subclasses

EditBox, EditLine

Constant Summary

Constants included from Common::State

Common::State::DISABLED_STATE

Constants included from Common::Style

Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS

Instance Attribute Summary

Attributes inherited from Common::UIElement

#app, #dimensions, #gui, #parent

Instance Method Summary collapse

Methods included from Common::State

#after_initialize, #enabled?, #state=

Methods included from Common::Focus

#focus, #focused?

Methods included from Common::Changeable

#change

Methods included from Common::SafelyEvaluate

#safely_evaluate

Methods inherited from Common::UIElement

#add_to_parent, #after_initialize, #create_backend, #create_dimensions, #initialize, #needs_rotate?, #painted?, #redraw_height, #redraw_left, #redraw_top, #redraw_width, #update_fill, #update_stroke

Methods included from Common::Style

#applicable_app_styles, #create_style_hash, included, #style, #style_init

Methods included from Common::Remove

#remove

Methods included from Common::Positioning

#_position, #displace, #move

Methods included from Common::Visibility

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

Methods included from Common::Inspect

#inspect, #to_s

Methods included from Common::Attachable

#attached_to

Constructor Details

This class inherits a constructor from Shoes::Common::UIElement

Instance Method Details

#before_initialize(styles, text) ⇒ Object



9
10
11
# File 'shoes-core/lib/shoes/input_box.rb', line 9

def before_initialize(styles, text)
  styles[:text] = text.to_s
end

#caret_to(index) ⇒ Object



31
32
33
# File 'shoes-core/lib/shoes/input_box.rb', line 31

def caret_to(index)
  @gui.caret_to(index)
end

#handle_block(blk) ⇒ Object



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

def handle_block(blk)
  change(&blk) if blk
  update_visibility
end

#highlight_text(start_index, final_index) ⇒ Object



27
28
29
# File 'shoes-core/lib/shoes/input_box.rb', line 27

def highlight_text(start_index, final_index)
  @gui.highlight_text(start_index, final_index)
end

#readonly?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'shoes-core/lib/shoes/input_box.rb', line 35

def readonly?
  state.to_s == "readonly"
end

#textObject



18
19
20
# File 'shoes-core/lib/shoes/input_box.rb', line 18

def text
  @gui.text
end

#text=(value) ⇒ Object



22
23
24
25
# File 'shoes-core/lib/shoes/input_box.rb', line 22

def text=(value)
  style(text: value.to_s)
  @gui.text = value.to_s
end

#update_from_stateObject



39
40
41
42
# File 'shoes-core/lib/shoes/input_box.rb', line 39

def update_from_state
  super
  @gui.readonly = readonly?
end