Commit aa3aa469 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix regression with saveas/open callbacks not getting called, plus a minor fix...

fix regression with saveas/open callbacks not getting called, plus a minor fix for showing the file extension in the dialog
parent 4b5df822
......@@ -38,15 +38,6 @@ function open_external_doc(target) {
gui.Shell.openExternal(target);
}
var chooser = document.querySelector("#fileDialog");
chooser.addEventListener("change", function(evt) {
var file_array = this.value;
// reset value so that we can open the same file twice
this.value = null;
pdgui.menu_open(file_array);
console.log("tried to open something");
}, false);
document.getElementById("dsp_control").addEventListener("click",
function(evt) {
var dsp_state = this.checked ? 1 : 0;
......@@ -357,6 +348,13 @@ function nw_create_pd_window_menus () {
});
span.innerHTML = input;
var chooser = document.querySelector("#fileDialog");
chooser.onchange = function() {
var file_array = this.value;
// reset value so that we can open the same file twice
this.value = null;
pdgui.menu_open(file_array);
console.log("tried to open something");
};
chooser.click();
}
}));
......
......@@ -32,7 +32,6 @@ function text_to_fudi(text) {
text = text.replace(/(?!\\)(,|;)/g, " \\$1 "); // escape "," and ";"
text = text.replace(/\{|\}/g, ""); // filter "{" and "}"
text = text.replace(/\s+/g, " "); // filter consecutive /s
return text;
}
......@@ -348,7 +347,8 @@ var canvas_events = (function() {
}
;
// Dialog events
// Dialog events -- these are set elsewhere now because of a bug
// with nwworkingdir
document.querySelector("#saveDialog").addEventListener("change",
function(evt) {
pdgui.saveas_callback(name, this.value);
......
......@@ -356,18 +356,28 @@ function gui_canvas_saveas (name, initfile, initdir) {
if (!fs.existsSync(initdir)) {
initdir = pwd;
}
// If we don't have a ".pd" file extension (e.g., "Untitled-1", add one)
if (initfile.slice(-3) !== ".pd") {
initfile += ".pd";
}
// This is complicated because of a bug... see above
input = build_file_dialog_string({
style: "display: none;",
type: "file",
id: "saveDialog",
nwsaveas: initdir + '/' + initfile + ".pd",
nwsaveas: initdir + '/' + initfile,
nwworkingdir: initdir,
accept: ".pd"
});
post("input is " + input);
span.innerHTML = input;
chooser = patchwin[name].window.document.querySelector("#saveDialog");
chooser.onchange = function() {
saveas_callback(name, this.value);
// reset value so that we can open the same file twice
this.value = null;
console.log("tried to save something");
}
chooser.click();
}
......@@ -930,7 +940,7 @@ function connect () {
client = new net.Socket();
client.setNoDelay(true);
// uncomment the next line to use fast_parser (then set its callback below)
// client.setEncoding("utf8");
//client.setEncoding("utf8");
client.connect(PORT, HOST, function() {
console.log("CONNECTED TO: " + HOST + ":" + PORT);
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment