c# - 如何检测按钮是否没有被点击/如果没有点击如何让某些东西消失
问题描述
嗨,我正在制作卡片清单,其中有 4 张选定的卡片和可供选择的卡片网格。按下卡时,我会弹出一个按钮,您可以按该按钮来选择卡,但我的问题是我不知道如何使该按钮消失。
我希望在按下一张卡时显示一个选择按钮,然后按下另一个将使其消失,或者按其他任何按钮将使其消失。但我不知道该怎么做。
下拉 ui 模板有这个内置的客栈,当单击下拉选项时,会显示选项,当单击其他任何内容时,它会消失,我想要那个。
编辑:为了进一步澄清,我有 2 个按钮,1 个使另一个可见,当单击按钮本身以外的任何其他内容时,另一个将消失。这就是我所拥有的
任何想法在互联网上随机奇妙的陌生人
爱
解决方案
As I misunderstood your problem the first time, I'll write it the second time.
I think this is really simple to solve, so basically create a huge and transparent button which will detect all of the clicks besides from the cards and buttons.
So my solution is:
- Create a button called for example "Background" and set its scale to an enormous values like 1000 to cover the whole screen all time.
- Set all of the button's colors (Normal Color, Highlighted, Pressed, etc.) to transparent - basically set the Alpha value to 0
- The button has to be above all of the other buttons in the Hierarchy of
Canvas
(or however you called it) in order to work as a background and not cover up other buttons. - Detect the clicks on the "Background", which will just hide the "Select" and the "Info" button.
I hope this time it will work.
推荐阅读
- python - numpy 有一个名为 math 的模块吗?
- reactjs - 如何在反应中使用 Hooks 更新设备宽度的状态
- javascript - 页面上特定元素上的滚动指示器
- spring-cloud-deployer-kubernetes - 使用 containerCommand 属性执行多行命令
- pseudocode - TSP 的大 O 时间复杂度
- postgresql - Karate + Gradle:有没有办法在 .java 文件中获取环境变量值并根据 env 变量值定义 Postgres DB 配置?
- angular-material - 控制 Angular Material 对话框大小的最佳做法是什么?
- spring-boot - 即使在配置之后也没有使用 Spring Boot jpa 二级缓存
- javascript - (反应)如何重定向到搜索结果页面
- c++ - 为什么此代码适用于 C++ 中的 2 Keys Keyboard 问题?