# Using set\_sensitive on a button

**URL:** <https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709>\
**Category:** Ruby-Gnome 2\
**Created:** [September 11, 2011, 7:42pm UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709 "2011-09-11T19:42:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 11, 2011, 7:42pm UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709/1 "2011-09-11T19:42:42Z")

</div>

Hi.

I use .set\_sensitive on a button.

That button then becomes:

- non functional (you can’t click on it)
- greyed out in case it has an image

I am fine with the non-functional part of the button. I don’t want it to  
respond on anymore click events.

But, that greyed out part is a problem. The colourful image it has  
suddenly is greyish, and that looks ugly.

Is there a way to disable the click functionality of a button otherwise?

Something like …

button.disable\_event(:click)

Or something similar?

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 11, 2011, 7:56pm UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709/2 "2011-09-11T19:56:33Z")

</div>

On Sun, Sep 11, 2011 at 19:42, Marc H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> suddenly is greyish, and that looks ugly.  
> You’re in Gtk+ territory again. Please realize that Ruby-GNOME2 is  
> simply a wrapper around various “GNOME” libraries. All Ruby-GNOME2  
> does, more or less, is provide data conversion between Ruby types and  
> C/GLib/Gtk+ types.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 13, 2011, 6:08am UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709/3 "2011-09-13T06:08:04Z")

</div>

That is nice but your statement has not helped much. ☹

My goal is to stay within the Ruby world when I try to solve a problem  
in the ruby-gtk / ruby-gnome world.

I need this functionality for a ruby-gtk implementation of the game  
Mastermind.

[![](https://www.c-sharpcorner.com/UploadFile/mgold/MastermindAI11152005035151AM/Images/MastermindAI.jpg) ](https://www.c-sharpcorner.com/UploadFile/mgold/MastermindAI11152005035151AM/Images/MastermindAI.jpg)

On the right side, I display the solution if an event happens.

My current solution is to show the buttons there, but without making  
them CLICKABLE.

I am using .set\_sensitive for this, which is totally inadequate. The  
buttons are greyish suddenly and I CAN NOT SEE THE OLD IMAGE ANYMORE.

So all I really need is the answer to the question how to disable a  
button to be clickable.

PS: Plus, we should shape up … the WWW has CSS and Javascript. Those  
things start to become really trivial in Javascript.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 13, 2011, 6:54am UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709/4 "2011-09-13T06:54:44Z")

</div>

On Tue, 2011-09-13 at 06:08 +0200, Marc H. wrote:

> My current solution is to show the buttons there, but without making  
> them CLICKABLE.
> 
> So all I really need is the answer to the question how to disable a  
> button to be clickable.

Perhaps one approach would be to not use Gtk buttons at all. You could  
simply use a Gtk::Image. You would need to wrap the image in a  
Gtk::EventBox in order to get mouse click events - the documentation for  
Gt;::Image has an example.

Regards  
Grant

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 13, 2011, 1:48pm UTC](https://www.ruby-forum.com/t/using-set-sensitive-on-a-button/211709/5 "2011-09-13T13:48:38Z")

</div>

On Tue, Sep 13, 2011 at 06:08, Marc H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> That is nice but your statement has not helped much. ☹

Nice? How?

> My goal is to stay within the Ruby world when I try to solve a problem  
> in the ruby-gtk / ruby-gnome world.

My point was that your goals may not be in alignment with the goals of  
this list.

> So all I really need is the answer to the question how to disable a  
> button to be clickable.

Again, this list isn’t primarily about answering questions pertaining  
to doing things in Gtk+, through Ruby-GNOME2 libraries or otherwise.  
I’m not stopping you from asking or anyone answering, but please  
realize that there are lists that are better suited for these  
questions, for example,  
[http://mail.gnome.org/mailman/listinfo/gtk-list](http://mail.gnome.org/mailman/listinfo/gtk-list).

The Ruby-GNOME2 project is extremely strapped for development  
resources and I’m sure you wouldn’t want to use up our limited time  
when another mailing list may have more resources to spare.

That said, your bug reports are much appreciated and it’s great to see  
people using Ruby-GNOME2.

I also see that Grant has provided a possible solution. I hope that  
it works for you!
