class LUIT::TextArea
Attributes
field[R]
Public Class Methods
new(holder, id, x, y, maxChar, h)
click to toggle source
Calls superclass method
LUIT::LUITElement::new
# File lib/luit.rb, line 113 def initialize(holder, id, x, y, maxChar, h) h = [10, h].max @font = Gosu::Font.new(h) w = @font.text_width("W" * maxChar) + 20 @maxChar = maxChar super(holder, id, x, y, w, h + 20) @typing = false @field = Gosu::TextInput.new @window = LUIT.window end
Public Instance Methods
draw(x = 0, y = 0)
click to toggle source
# File lib/luit.rb, line 139 def draw(x = 0, y = 0) x = x + @x y = y + @y Gosu::draw_rect(x, y, @w, @h, @typing ? 0xffffffff : LUIT.uiColor, LUIT.z) @font.draw(@field.text, x + 10, y + 10, LUIT.z + 1, 1, 1, 0xff000000) end
text()
click to toggle source
# File lib/luit.rb, line 124 def text return @field.text end
update(x = 0, y = 0)
click to toggle source
Calls superclass method
LUIT::LUITElement#update
# File lib/luit.rb, line 146 def update(x = 0, y = 0) super x += @x y += @y updateHover(x, y) if @field.text.size > @maxChar @field.text = @field.text[0..@maxChar] end if @typing @window.text_input = @field elsif @window.text_input == @field @window.text_input = nil end if Gosu::button_down?(Gosu::KbReturn) && @typing @typing = false @window.text_input = nil @holder.onClick(@id) end end