Class: Cura::Component::Textbox

Inherits:
Label show all
Defined in:
lib/cura/component/textbox.rb

Overview

A component containing editable text.

Instance Attribute Summary collapse

Attributes included from Attributes::HasAncestry

#parent

Attributes included from Attributes::HasOffsets

#offsets

Attributes included from Attributes::HasEvents

#event_handler

Instance Method Summary collapse

Methods inherited from Label

#bold=, #bold?, #draw, #height, #horizontal_alignment, #horizontal_alignment=, #lines, #text, #text=, #text_height, #text_width, #underline?, #underlined=, #vertical_alignment, #vertical_alignment=, #width

Methods included from Attributes::HasAttributes

included, #update_attributes

Methods inherited from Base

#application, #background, #contains_coordinates?, #cursor, #draw, #focus, #focused?, #foreground, inherited, #inspect, #pencil, type, #update

Methods included from Attributes::HasVisibility

#visible=, #visible?

Methods included from Attributes::HasRelativeCoordinates

#absolute_x, #absolute_y

Methods included from Attributes::HasCoordinates

#x, #x=, #y, #y=

Methods included from Attributes::HasAncestry

#ancestors, #parent?

Methods included from Attributes::HasOffsets

#border, #border=, #margin, #margin=, #padding, #padding=

Methods included from Attributes::HasColors

#background, #background=, #foreground, #foreground=

Methods included from Attributes::HasFocusability

#focusable=, #focusable?

Methods included from Attributes::HasEvents

included, #on_event

Methods included from Attributes::HasDimensions

#height, #resize, #width

Constructor Details

#initialize(attributes = {}) ⇒ Textbox

Returns a new instance of Textbox.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cura/component/textbox.rb', line 34

def initialize(attributes={})
  @focusable = true
  @foreground = Cura::Color.black
  @background = Cura::Color.white

  super

  # TODO
  # @width  = 1 if @width != :auto && @width < 1
  # @height = 1 if @height != :auto && @height < 1
end

Instance Attribute Details

#mask_characterString

Get the mask character for this textbox.

Returns:

  • (String)


60
61
62
# File 'lib/cura/component/textbox.rb', line 60

def mask_character
  @mask_character
end

Instance Method Details

#clearTextbox

Clear all characters within this textbox.

Returns:



49
50
51
52
53
54
55
# File 'lib/cura/component/textbox.rb', line 49

def clear
  @text = ""

  set_cursor_position

  self
end

#height=(value) ⇒ Integer

Set the height of this textbox.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


88
89
90
91
92
# File 'lib/cura/component/textbox.rb', line 88

def height=(value)
  super

  @height = 1 if @height < 1
end

#width=(value) ⇒ Integer

Set the width of this textbox.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


78
79
80
81
82
# File 'lib/cura/component/textbox.rb', line 78

def width=(value)
  super

  @width = 1 if @width < 1
end