Class: MittensUi::Textbox
- Inherits:
-
Core
- Object
- Core
- MittensUi::Textbox
show all
- Defined in:
- lib/mittens_ui/textbox.rb
Instance Attribute Summary
Attributes inherited from Core
#core_widget
Instance Method Summary
collapse
Methods inherited from Core
#hidden?, #hide, #remove, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(options = {}) ⇒ Textbox
Returns a new instance of Textbox.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 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
|
Instance Method Details
#clear ⇒ Object
25
26
27
|
# File 'lib/mittens_ui/textbox.rb', line 25
def clear
@textbox.text = ""
end
|
#enable_text_completion(data) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# 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 ⇒ Object
48
49
50
51
|
# File 'lib/mittens_ui/textbox.rb', line 48
def render
$vertical_box.pack_start(@textbox)
return self
end
|
#text ⇒ Object
44
45
46
|
# File 'lib/mittens_ui/textbox.rb', line 44
def text
@textbox.text
end
|