Bug in wxFlatNoteBook with wxRadioButton

BlitzMax Forums/Brucey's Modules/Bug in wxFlatNoteBook with wxRadioButton

Pete Rigz(Posted 2009) [#1]
Hello, really weird one this. It seems that when you setvalue on a radio button that is on a flatnotebook page that isn't showing, switching a page thereafter creates a wxEVT_COMMAND_RADIOBUTTON_SELECTED event.

I've knocked up a quick and dirty example. A flat note book with 2 tabs, and three radio buttons on each tab. I've connected the radio button events and just told it to log the button press in the debuglog. I've also connected the page change event for the notebook just to be able to setvalue the radio button on the other page which seems to create the bug. Just run the program and select "Blue", then click the position tab, and straight away you will see that will create a radio button event, click back to the colour tab and it'll raise another radio button event. Change pages again and it won't do it any more, until you fiddle with the buttons again.

I tested this with a normal notebook and that seemed fine. Anyway here's the code:



Any ideas?

Cheers!


Brucey(Posted 2009) [#2]
Works as expected on Mac... (ie. no extra events).

I'll have a look at Win32 in the morning :-)


Brucey(Posted 2009) [#3]
straight away you will see that will create a radio button event

You can fix this by defining your "left" button as the start of a new group with the wxRB_GROUP flag.

One down... one to go :-)


Pete Rigz(Posted 2009) [#4]
Ahh yeh, I must have assumed the form builder would add it for me as they were on a separate panel :)


Brucey(Posted 2009) [#5]
This appears to be an "issue" with Windows. I can understand why it might be happening, but I'm not sure how one would avoid it entirely.

On a hidden window, you Set a different radio button. It is checked, the other is unchecked.
However, when shown again, I believe the Windows UI hasn't updated the visual state of the old radio button, which it then toggles off, causing a "unchecked" event to be raised.

One way to ignore this would be to catch the event as normal, but only be interested in the event if IsChecked is true (ie. the button has just been clicked on).


Pete Rigz(Posted 2009) [#6]
Thanks for your help brucey. I've just changed it to use a standard notebook which works fine, which is a shame as I preferred the different styles available of the flat notebook. I couldn't find any workarounds including your ischecked idea.

Basically in my particle editor each effect has different properties spread over a few tabs with radio buttons for setting the emitter type like point, area, line etc. So if you're on a different tab and select an effect that emits at a point, then select an area effect, switching the tab thereafter would change it from an area to a point. So the event did actually have the isChecked flag set as true. Unless there's some other way of differentiating between the user clicking and the tab clicking for you? I couldn't see any.