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 9173233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:32:31+00:00 2026-06-17T16:32:31+00:00

I m working on a canvas style graphical interface using VS asp.net. I would

  • 0

enter image description here

I m working on a canvas style graphical interface using VS asp.net. I would like to create speech-bubbles with individual events. For example – the red-dot on my screen, if the client clicks on it, a speech bubble will appear to give more information about the event.

How do I make those events interactable ?

Right now I am I m using a simple canvas:

<canvas id="myCanvas" width="930" height="900"style="border:2px solid #000000;"></canvas> 

// function to draw a circle - x,y, radius, color: coordinates, radius and the color of the circle.
                function draw_circle(x, y, radius, color) {
                        ctx.beginPath();
                        ctx.arc(x, y, radius, 0, 2 * Math.PI, false);
                        ctx.fillStyle = color;
                        ctx.fill();
                        ctx.stroke();
                    }

// function to draw a triangle - x: Life event's x-coordinate on the timeline.
                function draw_triangle(x) {
                        ctx.fillStyle = 'purple';
                        ctx.strokeStyle = 'white';
                        ctx.lineWidth = 1;
                        ctx.beginPath();

                        ctx.moveTo(x, 560);
                        ctx.lineTo(x+5, 550);
                        ctx.lineTo(x-5, 550);
                        ctx.lineTo(x, 560);

                        ctx.fill();
                        ctx.stroke();
                        ctx.closePath();
                    }

etc..

I believe to make these events – circle, bar lines, triangles more interactable with speech bubble, I will have to modify this code… Can these javascript functions be made to be interactable? hoverover or onclick?

I looked at speech bubbles

http://www.scriptol.com/html5/canvas/speech-bubble.php

but I want something only related to specific events based on client side mouse click. only.

I want something like this:-

http://simile-widgets.org/wiki/Timeline_CustomEventDetailDisplay

But tailored to the code I am using.

  • 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-06-17T16:32:32+00:00Added an answer on June 17, 2026 at 4:32 pm

    If you want to draw a speech bubble on the canvas in response to a mouse click/hover, you have to capture the mouse x and y relative to the canvas position on the page, then determine if the part of the canvas that holds that circle was clicked/hovered.

    Personally I would create an object for each clickable region, give it x/y/width/height properties and then call a function when it is clicked. Something like this:

    <canvas id="myCanvas" width="930" height="900"style="border:2px solid #000000;"></canvas>
    
    var buttons = [];
    
    var mouse = 
    {
        x: 0,
        y: 0
    }
    
    var buttons[] = new Button(100, 100, 100, 100, 'speechbubble');
    
    window.addEventListener('load', function()
    {
        addEventListener('mousemove', function(evt)
        {
            getMousePos(evt);
        }, false);
    
        addEventListener('click', clickHandler, false);
    
    }, false);
    
    function getMousePos(e)
    {
        mouse.x = e.pageX - document.getElementById('myCanvas').offsetLeft;
        mouse.y = e.pageY - document.getElementById('myCanvas').offsetTop;
    }
    
    function clickHandler()
    {
        for (var i = 0; i < buttons.length; i++)
        {
            if (buttons[i].inBounds()) buttons[i].execute();
        }
    }
    
    function Button(x, y, w, h, func)
    {
        this.x = x;
        this.y = y;
        this.width = w;
        this.height = h;
        this.func = func;
    }
    
    Button.prototype.execute = function()
    {
        switch (this.func)
        {
            case 'speechbubble':
                // do stuff here
            break;
        }
    }
    
    Button.prototype.inBounds = function()
    {
        if (mouse.x > this.x && mouse.x < this.x + this.width &&
            mouse.y > this.y && mouse.y < this.y + this.height) return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a Facebook Canvas App and I would like to only display
I'm working on a canvas-based game and am using window.addEventListener() to attach keyup and
Working on a small game using an HTML5 canvas, and javascript. And it's working
I am working with facebook app canvas which requires post. I am using express
I am working with the HTML5 canvas element. I am using the following javascript
i am working on an asp.net mvc3 application. I am trying to load a
I am working with canvas in android. i want to draw shapes on canvas
Let's say I have such PoC code snippet for working with canvas raw pixel
So I'm working on a particle emitter with javascript and canvas. And I want
I'm currently working on a JavaScript project that uses the HTML5 canvas as 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.