简体   繁体   English

为什么我的按钮在隐藏时不起作用?

[英]Why doesn’t my button work when it’s hidden?

I have some code here it is我这里有一些代码

 function setup() { createCanvas(1350, 715); var blueskin = createButton('BLUE') blueskin.mousePressed(changeblue) blueskin.position(100,400) blueskin.size(50,50) blueskin.style('display:none') } function changeblue(){ playercolr='blue' }
 <script src="https://cdn.jsdelivr.net/npm/p5@1.4.1/lib/p5.js"></script>

When the button is not hidden it works perfectly but whenever I change it to hidden it stops working I looked some stuff up and aren't buttons supposed to work even if hidden当按钮未隐藏时,它可以完美工作,但每当我将其更改为隐藏时,它就会停止工作我查看了一些东西,即使隐藏了按钮也不应该工作

Change the style from 'display:none' to 'visiblity: hidden' and then try it将样式从 'display:none' 更改为 'visiblity: hidden' 然后试试

visibility:hidden hides the element visibility:hidden 隐藏元素

display:none removes the element from the document display:none 从文档中删除元素

Try:尝试:

blueskin.style('display', 'none')

per p5js documentation: https://p5js.org/reference/#/p5.Element/style根据 p5js 文档: https://p5js.org/reference/#/p5.Element/style

The syntax should be style(property, value) rather than style(propertyAndValue)语法应该是 style(property, value) 而不是 style(propertyAndValue)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM