From 96b0bac3310a1807e9750d8cabc19df4c8485a8a Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Fri, 24 Jul 2015 15:37:07 -0400 Subject: [PATCH] abstracted out iemgui dialog bindings into generic dialog_bindings --- pd/nw/dialog_iemgui.html | 8 +------- pd/nw/pdgui.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pd/nw/dialog_iemgui.html b/pd/nw/dialog_iemgui.html index 5eb9e1d4d..991d2f86e 100644 --- a/pd/nw/dialog_iemgui.html +++ b/pd/nw/dialog_iemgui.html @@ -572,13 +572,7 @@ function add_events(name) { pdgui.remove_dialogwin(pd_object_callback); this.close(true); }); - document.onkeydown = function(evt) { - if (evt.keyCode === 13) { // enter - ok(); - } else if (evt.keyCode === 27) { // escape - cancel(); - } - }; + pdgui.dialog_bindings(name); } </script> diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 3689b6faa..88e70ccf4 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -3894,3 +3894,15 @@ function gui_find_lowest_and_arrange(cid, reference_element_tag, objtag) { } } } + +// Bindings for dialog menu of iemgui, canvas, etc. +exports.dialog_bindings = function(did) { + var dwin = dialogwin[did].window; + dwin.document.onkeydown = function(evt) { + if (evt.keyCode === 13) { // enter + dwin.ok(); + } else if (evt.keyCode === 27) { // escape + dwin.cancel(); + } + }; +} -- GitLab