aaronmck Posted September 14, 2016 Share Posted September 14, 2016 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! Quote Link to comment Share on other sites More sharing options...
royibernthal Posted September 14, 2016 Share Posted September 14, 2016 Did you take a look at Canvas2D? What do you use to create your buttons? Quote Link to comment Share on other sites More sharing options...
aaronmck Posted September 14, 2016 Author Share Posted September 14, 2016 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>'); Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 14, 2016 Share Posted September 14, 2016 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; ... }); aaronmck 1 Quote Link to comment Share on other sites More sharing options...
aaronmck Posted September 14, 2016 Author Share Posted September 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.