# Gtk::Button and activating it / disabling activation

**URL:** <https://www.ruby-forum.com/t/gtk-button-and-activating-it-disabling-activation/76868>\
**Category:** Ruby-Gnome 2\
**Created:** [November 21, 2006, 8:46pm UTC](https://www.ruby-forum.com/t/gtk-button-and-activating-it-disabling-activation/76868 "2006-11-21T20:46:45Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [November 21, 2006, 8:46pm UTC](https://www.ruby-forum.com/t/gtk-button-and-activating-it-disabling-activation/76868/1 "2006-11-21T20:46:45Z")

</div>

Hi ruby-gnomists 🙂

If i put a button into a widget, I can move to  
it when i use the arrow keys. This is a useful  
feature, but not necessarily always.  
Is there a way to disable activating a button  
with the arrow keys?  
It also puts a “raster” around the button when  
its activated, and I dont always like to  
have this raster.

Attached is sample code, I use Canvas because I originally  
had a Canvas field where I moved some icons. When  
I did hit cursor\_down key, the lower button was  
activated though, and this was a bit annoying  
to see, thus I later changed my code to use an  
EventBox instead of Gtk::Button:

```
require 'gtk2'
require 'gnomecanvas2'
w=Gtk::Window.new
box=Gtk::VBox.new
box.add Gtk::Label.new('Test')
box.add Gnome::Canvas.new
box.add Gtk::Button.new('Button1')
box.add Gtk::Button.new('Button2')
w.add(box)
w.set_size_request 400,400
w.show_all
Gtk.main

```

–

* * *

Get your free email from [http://www.linuxmail.org](http://www.linuxmail.org)

Powered by Outblaze

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<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:** [November 21, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/gtk-button-and-activating-it-disabling-activation/76868/2 "2006-11-21T21:16:50Z")

</div>

On Tue, Nov 21, 2006 at 08:39:09PM +0100, Roebe XXX wrote:

> Hi ruby-gnomists 🙂

Hey!

Responses inline.

> If i put a button into a widget, I can move to  
> it when i use the arrow keys. This is a useful  
> feature, but not necessarily always.  
> Is there a way to disable activating a button  
> with the arrow keys?

You can make the button not able to be focused by setting

button.can\_focus = false

> It also puts a “raster” around the button when  
> its activated, and I dont always like to

Do you mean the ‘pressed look’ when the button is clicked?

-pete

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
