# ListCtrl unexpected behavior

**URL:** <https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334>\
**Category:** wxRuby\
**Created:** [January 9, 2009, 3:52pm UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334 "2009-01-09T15:52:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [January 9, 2009, 3:52pm UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334/1 "2009-01-09T15:52:01Z")

</div>

Hi,

using ListCtrl, I realized that, capturing the selection event by using  
the  
macro evt\_list\_item\_selected, I get mistaken event of type ListItem  
instead  
of type ListEvent.  
I noticed that this occurs when i use the keyboard arrow keys to move  
through the list.

It can be shown in the example Bigdemo -\> wxListCtrl\_virtual causing the  
error.

my environment is

wxruby-1.9.9-x86-mswin32-60, ruby 1.8.6  
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]  
WinXP sp2

if i rememer well there was no problem with wxruby-1.9.8

regards,

bio.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [January 9, 2009, 5:35pm UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334/2 "2009-01-09T17:35:20Z")

</div>

one more detail:

the error occurs only alternating mouse clicks and keyboard arrow keys  
through the list.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [January 9, 2009, 11:49pm UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334/3 "2009-01-09T23:49:29Z")

</div>

Hi Fabio

Fabio P. wrote:

> wxruby-1.9.9-x86-mswin32-60, ruby 1.8.6  
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]  
> WinXP sp2

Thanks for the report. I think that at the root this is the same bug  
that others were encountering with Scintilla event handlers, which is  
now fixed in SVN. I will try and reproduce using the ListCtrl on Windows  
(the bug depends partly on how the OS allocates memory blocks).

Useful to know that it wasn’t a problem in 1.9.8 - will check see if any  
other classes might have this problem. It will be fixed for 2.0

cheers  
alex

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [January 10, 2009, 12:34am UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334/4 "2009-01-10T00:34:35Z")

</div>

Hi,

2009/1/9 Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > It can be shown in the example Bigdemo → wxListCtrl\_virtual causing the  
> > error.
> 
> Thanks for the report. I think that at the root this is the same bug that  
> others were encountering with Scintilla event handlers, which is now fixed  
> in SVN.

FYI, it works fine for me with the latest revision in SVN.

Cheers,

Chauk-Mean.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [January 10, 2009, 1:03am UTC](https://www.ruby-forum.com/t/listctrl-unexpected-behavior/157334/5 "2009-01-10T01:03:52Z")

</div>

Chauk-Mean P wrote:

> > Thanks for the report. I think that at the root this is the same bug that  
> > others were encountering with Scintilla event handlers, which is now fixed  
> > in SVN.
> 
> FYI, it works fine for me with the latest revision in SVN.

Cool, thanks.

I took another look at our SWIG wxRuby\_WrapWxEventInRuby function and  
there’s something in there which could potentially still cause these  
errors where an event handler receives an odd type of object instead of  
the correct Event object.

I’ll put a patch in to make it watertight, although it may well be that  
the commonest route for these memory mess-ups is already plugged.

cheers  
alex
