class MittensUi::Textbox
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
MittensUi::Core::new
# File lib/mittens_ui/textbox.rb, line 5 def initialize(options={}) @textbox = Gtk::Entry.new can_edit = options[:can_edit].nil? ? true : options[:can_edit] max_length = options[:max_length].nil? ? 200 : options[:max_length] has_password = options[:password].nil? ? false : options[:password] placeholder_text = options[:placeholder] || "" if has_password @textbox.set_visibility(false) end @textbox.set_editable(can_edit) unless can_edit.nil? @textbox.set_max_length(max_length) unless max_length.nil? @textbox.set_placeholder_text(placeholder_text) super(@textbox, options) end
Public Instance Methods
clear()
click to toggle source
# File lib/mittens_ui/textbox.rb, line 25 def clear @textbox.text = "" end
enable_text_completion(data)
click to toggle source
# File lib/mittens_ui/textbox.rb, line 29 def enable_text_completion(data) completion = Gtk::EntryCompletion.new @textbox.completion = completion model = Gtk::ListStore.new(String) data.each do |value| iter = model.append iter[0] = value end completion.model = model completion.text_column = 0 end
render()
click to toggle source
# File lib/mittens_ui/textbox.rb, line 48 def render $vertical_box.pack_start(@textbox) return self end
text()
click to toggle source
# File lib/mittens_ui/textbox.rb, line 44 def text @textbox.text end