canvas - Mouse Highlighting Interfering with HTML5 Game -
so, having lot of fun html5 canvas gaming. 1 issue, however, if using dom elements in addition canvas elements, clicking , dragging on canvas highlight , "select" dom elements. subsequent click operation start "drag" dom elements around instead of registering canvas.
it's extremely annoying, , cannot find way prevent it. there way make dom elements "not highlight-able" were? else having issue?
addenda: game shooter, hold mouse click down keep shooting. health , points stored inside dom elements. render score/health canvas, faster dom element.
in mousedown/click event handlers, add event.preventdefault() / return false.
example
window.addeventlistener('click', function(e) { e.preventdefault(); return false; }, false);
Comments
Post a Comment