# Wx::Grid and motion events, bug?

**URL:** <https://www.ruby-forum.com/t/wx-grid-and-motion-events-bug/194706>\
**Category:** wxRuby\
**Created:** [September 9, 2010, 9:59am UTC](https://www.ruby-forum.com/t/wx-grid-and-motion-events-bug/194706 "2010-09-09T09:59:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/49beb7/32.png) [@quintus](https://www.ruby-forum.com/u/quintus)\
**Post date:** [September 9, 2010, 9:59am UTC](https://www.ruby-forum.com/t/wx-grid-and-motion-events-bug/194706/1 "2010-09-09T09:59:27Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi there,

Doesn’t a Wx::Grid get motion events sent? This code demonstrates the  
problem:

* * *

#!/usr/bin/env ruby  
#Encoding: UTF-8  
require “wx”

class MyFrame \< Wx::Frame  
include Wx

def initialize(parent = nil)  
super(parent, title: “Test”, size: Size.new(400, 400))  
self.background\_colour = NULL\_COLOUR

```
StaticText.new(self, label: "") #Dummy
@grid = Grid.new(self, size: Size.new(300, 200))
@grid.create_grid(10, 10)
@grid.evt_motion{|e| p "!"; $stdout.flush}

```

end

end

class MyApp \< Wx::App  
include Wx

def on\_init  
@mainwindow = MyFrame.new  
@mainwindow.show  
end

end

x = MyApp.new  
x.main\_loop

* * *

If I hover the mouse above the grid, nothing happens, but if I put in a  
panel control instead of a grid, it works. Surprisingly, if I changed  
the line

@grid.evt\_motion{|e| p “!”; $stdout.flush}

to

THE\_APP.evt\_motion{|e| p “!”; $stdout.flush}

I get motion events for everything but the grid. As soon as the cursor  
enters the grid control, no output arrives anymore.  
What’s going on here? Is that a bug?

I’m working on Ubuntu Lucid. Here’s the uname -a:

Linux ikarus 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:21:58 UTC  
2010 x86\_64 GNU/Linux

and here’s my ruby -v:

ruby 1.9.2p0 (2010-08-18 revision 29036) [x86\_64-linux]

I compiled both Ruby and wxRuby from source.

Marvin  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.10 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iEYEARECAAYFAkyIk7MACgkQDYShvwAbcNntNQCfcw+zR78b6ZxoTImx+rCRzCeN  
khQAnjo4Zcix/0VkZqrwkz3f6x6XpCSM  
=tLGS  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![quintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/49beb7/32.png) [@quintus](https://www.ruby-forum.com/u/quintus)\
**Post date:** [September 10, 2010, 4:06pm UTC](https://www.ruby-forum.com/t/wx-grid-and-motion-events-bug/194706/2 "2010-09-10T16:06:46Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Am 09.09.2010 09:58, schrieb Quintus:

> Hi there,
> 
> Doesn’t a Wx::Grid get motion events sent? This code demonstrates the  
> problem:

# This problem seems to be quite serious. I just noticed that a Wx::Grid doesn’t get ANY mouse events sent:

#!/usr/bin/env ruby  
#Encoding: UTF-8  
require “wx”

class MyFrame \< Wx::Frame  
include Wx

def initialize(parent = nil)  
super(parent, title: “Test”, size: Size.new(400, 400))  
self.background\_colour = NULL\_COLOUR

```
StaticText.new(self, label: "") #Dummy
@grid = Grid.new(self, size: Size.new(300, 200))
@grid.create_grid(10, 10)
@grid.evt_left_down{|e| p "!"; $stdout.flush}
@grid.evt_left_up{|e| p "!"; $stdout.flush}
@grid.evt_motion{|e| p "!"; $stdout.flush}
@grid.evt_left_dclick{|e| p "!"; $stdout.flush}
@grid.evt_right_down{|e| p "!"; $stdout.flush}

```

end

end

class MyApp \< Wx::App  
include Wx

def on\_init  
@mainwindow = MyFrame.new  
@mainwindow.show  
end

end

# x = MyApp.new x.main\_loop

No way to get a single “!” out of the above program.  
Shall I file a bug on the tracker?

Marvin  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.10 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iEYEARECAAYFAkyKOvUACgkQDYShvwAbcNmM+ACeLxUBLq0mFUa62uUHiT1jxHoa  
9NMAnAslCNhfTb5OFgsPKXyNf0u9gSjN  
=Ikpy  
-----END PGP SIGNATURE-----
