Fix enabling radiobox buttons in wxQt
If a QGroupBox is disabled, then you cannot set any of its items to be enabled without first enabling it. Enabling/disabling it will set that value (true/false) on all of its items, although setting the QGroupBox to an enabled state which it already has does not result in this behaviour. Fix wxQt to match the expected wxRadioBox behaviour and allow the unit test to pass. Closes https://github.com/wxWidgets/wxWidgets/pull/1064
This commit is contained in:
committed by
Vadim Zeitlin
parent
91a87e765b
commit
2a64b65149
@@ -168,10 +168,42 @@ static QAbstractButton *GetButtonAt( const QButtonGroup *group, unsigned int n )
|
||||
|
||||
bool wxRadioBox::Enable(unsigned int n, bool enable)
|
||||
{
|
||||
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
|
||||
CHECK_BUTTON( qtButton, false );
|
||||
if ( enable && !m_qtGroupBox->isEnabled() )
|
||||
{
|
||||
m_qtGroupBox->setEnabled( true );
|
||||
|
||||
for ( unsigned int i = 0; i < GetCount(); ++i )
|
||||
{
|
||||
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, i );
|
||||
CHECK_BUTTON( qtButton, false );
|
||||
|
||||
qtButton->setEnabled( i == n );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
|
||||
CHECK_BUTTON( qtButton, false );
|
||||
qtButton->setEnabled(enable);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxRadioBox::Enable( bool enable )
|
||||
{
|
||||
if ( m_qtGroupBox->isEnabled() == enable )
|
||||
{
|
||||
for ( unsigned int i = 0; i < GetCount(); ++i )
|
||||
{
|
||||
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, i );
|
||||
CHECK_BUTTON( qtButton, false );
|
||||
qtButton->setEnabled( enable );
|
||||
}
|
||||
}
|
||||
|
||||
m_qtGroupBox->setEnabled( enable );
|
||||
|
||||
qtButton->setEnabled( enable );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user