aaronmck

Displaying an error message on screen

Recommended Posts

Hello

I have a mesh that loads when a button on screen is clicked. The button currently can only be clicked once so duplicate models can't be loaded.

I would like for there to be a message that displays on screen if the user clicks the button more than once.

var gpu_button_counter = 0;
                document.getElementById("gpu_button").addEventListener("click", function () {
                    if (gpu_button_counter > 0) { return false }
                    gpu_button_counter++;

I have this current code. Can anybody provide a solution as to how I would display a message on screen if the button is clicked more than once?

Thanks!

Share this post


Link to post
Share on other sites

I currently have a Canvas2D in my scene already which handles click events on the actual meshes, which was why I was looking to add a popup error message just to keep them separate.

To create the buttons I used:

$('body').append('<button id="gpu_button" style="position: absolute; right: 20px; top: 110px; font-size: 1em;">Graphics Card</button>');

 

Share this post


Link to post
Share on other sites

Most GUI designers would set the disabled property on the button listener.  It will grey it.  Users will figure out you can only click once.

document.getElementById("gpu_button").addEventListener("click", function () {
    document.getElementById("gpu_button").disabled = true;
    ...
});

 

Share this post


Link to post
Share on other sites
2 minutes ago, JCPalmer said:

Most GUI designers would set the disabled property on the button listener.  It will grey it.  Users will figure out you can only click once.


document.getElementById("gpu_button").addEventListener("click", function () {
    document.getElementById("gpu_button").disabled = true;
    ...
});

 

Hey, that looks like a better way to do it.

Thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.