Save or copy text in edit_box or line to an external file
JDsnyke opened this issue · comments
Using Shoes 3.3.7
How do I go about grabbing the text typed in an Edit_box and saving it to a file on a button click?
This is what i used. It created the file but it just stays empty...
Shoes.app do
Stack do
flow do
new_box = edit_box "placeholdertext"
end
flow do
button "Save" do
note_save = ask_save_file
File.open("#{note_save}", "a") do |copy|
copy.para "#{new_box.text}"
end
end
end
end
end
Edit : setting code to,
copy.write(new_box.text)
Still creates a file with empty content
I'm pretty new to all this. Any help is appreciated 😊
Hi @JDsnyke
You have copy.para "#{new_box.text}"
copy is File object which doesn't have a para method. You probably want copy.write "#{new_box.text}\n"
You may want a class variable @new_box = edit_box "placeholdertext"
because new_box may not be in scope.
Works like a charm. Thanks!