Class: LUIT::ScannerInput

Inherits:
Object
  • Object
show all
Defined in:
lib/luit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(holder, id, window) ⇒ ScannerInput

Returns a new instance of ScannerInput.



169
170
171
172
173
174
# File 'lib/luit.rb', line 169

def initialize(holder, id, window)
	@field = Gosu::TextInput.new
	@window = window
	@holder = holder
	@id = id
end

Instance Attribute Details

#scanningObject (readonly)

Returns the value of attribute scanning.



168
169
170
# File 'lib/luit.rb', line 168

def scanning
  @scanning
end

Instance Method Details

#scanObject



188
189
190
191
# File 'lib/luit.rb', line 188

def scan
	@scanning = true
	@window.text_input = @field
end

#stopObject



183
184
185
186
# File 'lib/luit.rb', line 183

def stop
	@scanning = false
	@window.text_input = nil if @window.text_input == @field
end

#updateObject



176
177
178
179
180
181
# File 'lib/luit.rb', line 176

def update
	if Gosu::button_down?(Gosu::KbReturn) && @scanning
		@holder.onScan(@field.text)
		@field.text = ""
	end
end