Handle toggle() signal too in wxQtAction

Check the item in toggle() signal and send the event in triggered() signal
which emitted after.

We need this separation because triggered() is not emitted when setChecked()
or toggle() is called. The wxQtActionGroup (will be added in the next commit)
uses one of them to synchronize QActions with their wx wrappers and the menu
test will eventually pass.
This commit is contained in:
ali kettab 2022-11-23 08:27:48 +01:00
parent 993a7e4284
commit 3dc2bb7b98

View file

@ -35,6 +35,7 @@ public:
}
private:
void onActionToggled( bool checked );
void onActionTriggered( bool checked );
const wxWindowID m_mitemId;
@ -180,6 +181,7 @@ wxQtAction::wxQtAction( wxMenu *handler, int id, const wxString &text, const wxS
break;
}
connect( this, &QAction::toggled, this, &wxQtAction::onActionToggled );
connect( this, &QAction::triggered, this, &wxQtAction::onActionTriggered );
UpdateShortcutsFromLabel( text );
@ -196,8 +198,12 @@ void wxQtAction::UpdateShortcutsFromLabel(const wxString& text)
#endif // wxUSE_ACCEL
}
void wxQtAction::onActionTriggered( bool checked )
void wxQtAction::onActionToggled( bool checked )
{
GetMenu()->Check(m_mitemId, checked);
}
void wxQtAction::onActionTriggered( bool checked )
{
GetMenu()->SendEvent(m_mitemId, m_isCheckable ? checked : -1 );
}