Fix some global event handlers interfering

main
Isaiah Odhner 2014-11-20 10:11:20 -05:00
parent f7adb945de
commit 8c8d15cafc
2 changed files with 10 additions and 6 deletions

View File

@ -41,8 +41,7 @@
* Tool options flicker... *and lag*, when they're redrawn in quick succession
* Global event handlers interfering with stuff
* In Image > Attributes and other places
* You can't copy, paste, cut or drag&drop in the inputs
* You can't click on the radio option labels when text is selected!
* You can't drag&drop in the inputs
* In Help > About Paint and other places
* You can't select text
* You can't drag links

View File

@ -283,8 +283,13 @@ $G.on("keydown", function(e){
}
});
$G.on("cut copy paste", function(e){
// @TODO: check document.activeElement for any input related elements
if(textbox){ return; }
if(
document.activeElement instanceof HTMLInputElement ||
document.activeElement instanceof HTMLTextAreaElement
){
// Don't prevent or interfere with cutting/copying/pasting within inputs or textareas
return;
}
e.preventDefault();
var cd = e.originalEvent.clipboardData || window.clipboardData;
@ -501,8 +506,8 @@ $body.on("mousedown contextmenu", function(e){
if(
e.target instanceof HTMLSelectElement ||
e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLInputElement &&
e.target.type !== "color"
(e.target instanceof HTMLLabelElement && e.type !== "contextmenu") ||
(e.target instanceof HTMLInputElement && e.target.type !== "color")
){
return true;
}