Skip to content

Commit

Permalink
prevent 'enter' (ascii 13) in dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Grahn committed Dec 7, 2023
1 parent e3ab76a commit 7e60046
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ document.addEventListener("visibilitychange", () => {loopMeas.splice(0);});
//add some hotkeys
window.addEventListener("keydown", function(e){
e.stopPropagation();
if($("input").is(":focus")||$("textarea").is(":focus")) return;
if($("input").is(":focus")) return;
else if ($("textarea").is(":focus")){
if(e.which==13) e.preventDefault(); //prevent newline in textarea
return;
}
else e.preventDefault();
if (e.which==27 || e.which==76 //"Esc" or "L"
&& !loopButton.disabled
Expand Down Expand Up @@ -335,7 +339,7 @@ window.addEventListener("keyup", function(e){
// [{r:<rows>, c:<cols>}]);
var promptDialog=function(onclose, title, text, placeholder, input, size={r:4,c:50}){
let z=$(
'<div style="width: fit-content; display: inline-block;"><p>' +
'<div style="width:fit-content;display:inline-block;"><p>' +
text +
'</p><textarea'+
(placeholder ? ' placeholder="'+placeholder+'"' : "")+
Expand All @@ -360,14 +364,14 @@ var promptDialog=function(onclose, title, text, placeholder, input, size={r:4,c:
text: "Cancel",
click: function(){
ret=input;
$(this).dialog( "close" );
$(this).dialog("close");
}
},
{
text: "Ok",
click: function(){
ret=$(this).find("textarea").val();
$(this).dialog( "close" );
$(this).dialog("close");
}
},
],
Expand Down
Binary file modified zip/ABLoopPlayer.zip
Binary file not shown.

0 comments on commit 7e60046

Please sign in to comment.