Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:15:44+00:00 2026-05-24T14:15:44+00:00

I have a drawing application using html5 canvas. When the user is drawing and

  • 0

I have a drawing application using html5 canvas. When the user is drawing and pen slips out of the canvas area, chrome highlights html elements on the page in light blue or yellow.

screen shot

This is disruptive to the drawing experience. Is there a way to prevent such highlight from happening?

The event handling and drawing code is based off of this post: http://jsfiddle.net/rnNFB/1/

var x ;
var y ;

var lower = $('#lower').get(0).getContext('2d') ;
var upper = $('#upper').get(0).getContext('2d') ;

var dragging = false ;

function drawStroke(ctx){
    var i ;
    ctx.strokeStyle='rgba(0,0,0,0.5)' ;
    ctx.lineWidth=10 ;
    ctx.beginPath() ;
    ctx.moveTo(x[0],y[0]) ;
    for (i=1; i < x.length; i++){
        ctx.lineTo(x[i],y[i]) ;
    }
    ctx.stroke() ;
}

$('#upper').mousedown(function(e){
    x=[e.layerX];
    y=[e.layerY];
    dragging=true}) ;

$('#upper').mousemove(function(e){
    if (dragging){
        x.push(e.layerX);
        y.push(e.layerY);
        upper.clearRect(0,0,upper.canvas.width,upper.canvas.height) ;
        drawStroke(upper) ;
    }}) ;

$('#upper').mouseup(function(e){
    dragging = false ;
    upper.clearRect(0,0,upper.canvas.width,upper.canvas.height) ;
    drawStroke(lower) ;
}) ;

If you add some h1 tags above the canvas tags then draw on the canvas, dragging outside the bounding box, you will see a blue highlight. Is there a way to prevent this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:15:45+00:00Added an answer on May 24, 2026 at 2:15 pm

    Apply the following CSS class to the elements that should be unselectable. It can also just be applied to body (though, best practise might be to only disable user selection on elements that really need it).

    .unselectable {
      user-select: none;
    }
    

    off-topic but it might also be interesing for the app: If you select a big lineWidth in the jsFiddle and move the mouse very slowly, you can see some ugly effects (blocks) in the sketches. Always check that the distance from the onmousemove (while dragging) coordinate to the last coordinate is not too small. For example, only add the coordinates to the sketch if the distance is more than about 1/6 of the linewith.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html5 canvas drawing application similar to this http://jsfiddle.net/rnNFB/1/ , but using
In my WPF application I have some drawing functionality. I have solved this using
In my WPF application I have a Canvas in which I do some drawing.
I have recently focused on drawing some cool shapes in a HTML 5.0 canvas.
I have a JavaScript application that lets users move shapes around a drawing area,
I have a drawing application in Android that allows the user to draw with
i have problem with using bitmap in console application in c#. I included system.drawing
I am currently trying to program an online drawing program using the HTML5 canvas.
I'm using Flash 10.3 in Firefox 7 and Chrome 14. I have some HTML
I have a prototype of a simple drawing application. When the user drags a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.