# enable and disable a button

**URL:** <https://discourse.processing.org/t/enable-and-disable-a-button/15721>\
**Category:** Processing\
**Created:** [November 22, 2019, 3:27pm UTC](https://discourse.processing.org/t/enable-and-disable-a-button/15721 "2019-11-22T15:27:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdecaro](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pdecaro](https://discourse.processing.org/u/pdecaro)\
**Post date:** [November 22, 2019, 3:27pm UTC](https://discourse.processing.org/t/enable-and-disable-a-button/15721/1 "2019-11-22T15:27:31Z")

</div>

Hello, I have the problem of disabling a key after pressing it. in practice I created two “on”, “off” buttons. When I press “on”, “off” is enabled and “on” must be disabled, and vice versa. I could not find a disbled-enabled option if it exists in processing.Can you help me. Thanks Paul

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 22, 2019, 3:35pm UTC](https://discourse.processing.org/t/enable-and-disable-a-button/15721/2 "2019-11-22T15:35:25Z")

</div>

hi Paul,  
could you share your code, that we can see how keys / buttons / work together.

it sounds like a toggle action, what actually would need ONE (ON / OFF ) button only  
but operated from key board by 2 keys? or 2 times press same key?

if you have 2 full functional buttons but you want them to work  
like a option group ( only ONE can be selected )  
you need some extra code what resets the other if one is set.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 22, 2019, 3:36pm UTC](https://discourse.processing.org/t/enable-and-disable-a-button/15721/3 "2019-11-22T15:36:37Z")

</div>

You have to store this Information in new variables and act accordingly

Eg. for each button a boolean variable

you can toggle it with on1 = ! on1;

the ! means not

Chrisir
