Commit 3bc84155 authored by Jonathan Wilkes's avatar Jonathan Wilkes

fix bug with menu_open not getting triggered from a canvas window

parent bc85bd22
......@@ -381,6 +381,8 @@ function nw_create_pd_window_menus(gui, w) {
});
span.innerHTML = input;
var chooser = w.document.querySelector("#fileDialog");
// Hack-- we have to set the event listener here because we
// changed out the innerHTML above
chooser.onchange = function() {
var file_array = this.value;
// reset value so that we can open the same file twice
......
......@@ -5,10 +5,10 @@
type="text/css" href="css/default.css">
</head>
<body id="patch_body">
<span id = fileDialogSpan>
<span id = "fileDialogSpan">
<input style="display:none;" id="fileDialog" type="file" multiple />
</span>
<span id = saveDialogSpan>
<span id = "saveDialogSpan">
<input style="display:none;" id="saveDialog" type="file"
nwsaveas nwworkingdir accept=".pd" />
</span>
......
......@@ -376,18 +376,23 @@ var canvas_events = (function() {
pdgui.saveas_callback(name, this.value);
// reset value so that we can open the same file twice
this.value = null;
console.log("tried to open something");
}, false
);
document.querySelector("#fileDialog").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");
console.log("tried to save something");
}, false
);
// The following is commented out because we have to set the
// event listener inside nw_create_pd_window_menus due to a
// bug with nwworkingdir
//document.querySelector("#fileDialog").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\n\n\n\n\n\n\n\n");
// }, false
//);
document.querySelector("#openpanel_dialog").addEventListener("change",
function(evt) {
var file_string = this.value;
......@@ -663,13 +668,24 @@ function nw_create_patch_window_menus(gui, w, name) {
var input, chooser,
span = w.document.querySelector("#fileDialogSpan");
input = pdgui.build_file_dialog_string({
id: "fileDialog",
nwworkingdir: "/user/home",
style: "display: none;",
type: "file",
id: "fileDialog",
nwworkingdir: "/user/home",
multiple: null,
accept: ".pd,.pat,.mxt,.mxb,.help"
});
span.innerHTML = input;
chooser = w.document.querySelector("#fileDialog");
// Hack-- we have to set the event listener here because we
// changed out the innerHTML above
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();
}
});
......
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