Class: MPTextField

Inherits:
UITextField
  • Object
show all
Includes:
MotionPrime::SupportControlContentAlignment, MotionPrime::SupportKeyValueStore, MotionPrime::SupportPaddingAttribute
Defined in:
motion-prime/support/mp_text_field.rb

Constant Summary

Constants included from MotionPrime::SupportControlContentAlignment

MotionPrime::SupportControlContentAlignment::VERTICAL_ALIGNMENT_CONSTS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MotionPrime::SupportControlContentAlignment

#bounds_height, #line_height, #padding_bottom, #padding_top, #setContentVerticalAlignment

Methods included from MotionPrime::SupportPaddingAttribute

#apply_padding, #apply_padding!, #apply_padding?, #padding_bottom, #padding_insets, #padding_left, #padding_right, #padding_top

Methods included from MotionPrime::SupportKeyValueStore

#setValue

Instance Attribute Details

#placeholderAlignmentObject

Returns the value of attribute placeholderAlignment.



12
13
14
# File 'motion-prime/support/mp_text_field.rb', line 12

def placeholderAlignment
  @placeholderAlignment
end

#placeholderColorObject

Returns the value of attribute placeholderColor.



12
13
14
# File 'motion-prime/support/mp_text_field.rb', line 12

def placeholderColor
  @placeholderColor
end

#placeholderFontObject

Returns the value of attribute placeholderFont.



12
13
14
# File 'motion-prime/support/mp_text_field.rb', line 12

def placeholderFont
  @placeholderFont
end

#readonlyObject

Returns the value of attribute readonly.



12
13
14
# File 'motion-prime/support/mp_text_field.rb', line 12

def readonly
  @readonly
end

Class Method Details

.default_padding_leftObject



14
15
16
# File 'motion-prime/support/mp_text_field.rb', line 14

def self.default_padding_left
  5
end

.default_padding_rightObject



18
19
20
# File 'motion-prime/support/mp_text_field.rb', line 18

def self.default_padding_right
  5
end

Instance Method Details

#drawPlaceholderInRect(rect) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'motion-prime/support/mp_text_field.rb', line 38

def drawPlaceholderInRect(rect)
  font_diff = self.font.pointSize - placeholder_font.pointSize
  rect.origin.y += font_diff/2.0
  color = self.placeholderColor || :gray.uicolor
  color.setFill

  truncation = :tail_truncation.uilinebreakmode
  alignment = (placeholderAlignment || :left.nstextalignment)
  self.placeholder.drawInRect(rect, withFont: placeholder_font, lineBreakMode: truncation, alignment: alignment)
end

#editingRectForBounds(bounds) ⇒ Object

text position



31
32
33
34
35
36
# File 'motion-prime/support/mp_text_field.rb', line 31

def editingRectForBounds(bounds)
  @_line_height = self.font.pointSize
  rect = calculate_rect_for(bounds)
  @_line_height = nil
  rect
end

#textRectForBounds(bounds) ⇒ Object

placeholder position



23
24
25
26
27
28
# File 'motion-prime/support/mp_text_field.rb', line 23

def textRectForBounds(bounds)
  @_line_height = font.pointSize
  rect = calculate_rect_for(bounds)
  @_line_height = nil
  rect
end