Merge branch 'updateui-ischeckable'

Add a flag to wxUpdateUIEvent to tell if the item supports the check
action.

See https://github.com/wxWidgets/wxWidgets/pull/2027
This commit is contained in:
Vadim Zeitlin
2020-09-02 19:34:05 +02:00
8 changed files with 53 additions and 7 deletions

View File

@@ -1546,7 +1546,7 @@ void wxAuiToolBar::ToggleTool(int tool_id, bool state)
{
wxAuiToolBarItem* tool = FindTool(tool_id);
if (tool && (tool->m_kind == wxITEM_CHECK || tool->m_kind == wxITEM_RADIO))
if ( tool && tool->CanBeToggled() )
{
if (tool->m_kind == wxITEM_RADIO)
{
@@ -1587,13 +1587,8 @@ bool wxAuiToolBar::GetToolToggled(int tool_id) const
{
wxAuiToolBarItem* tool = FindTool(tool_id);
if (tool)
{
if ( (tool->m_kind != wxITEM_CHECK) && (tool->m_kind != wxITEM_RADIO) )
return false;
if ( tool && tool->CanBeToggled() )
return (tool->m_state & wxAUI_BUTTON_STATE_CHECKED) ? true : false;
}
return false;
}
@@ -2200,6 +2195,9 @@ void wxAuiToolBar::DoIdleUpdate()
wxUpdateUIEvent evt(item.m_toolId);
evt.SetEventObject(this);
if ( !item.CanBeToggled() )
evt.DisallowCheck();
if (handler->ProcessEvent(evt))
{
if (evt.GetSetEnabled())

View File

@@ -617,6 +617,9 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source)
wxUpdateUIEvent event(itemid);
event.SetEventObject( this );
if ( !item->IsCheckable() )
event.DisallowCheck();
if ( source->ProcessEvent(event) )
{
// if anything changed, update the changed attribute

View File

@@ -739,6 +739,9 @@ void wxToolBarBase::UpdateWindowUI(long flags)
wxUpdateUIEvent event(toolid);
event.SetEventObject(this);
if ( !tool->CanBeToggled() )
event.DisallowCheck();
if ( evtHandler->ProcessEvent(event) )
{
if ( event.GetSetEnabled() )

View File

@@ -324,6 +324,9 @@ bool wxMenu::HandleCommandUpdateStatus( wxMenuItem* item, wxWindow* senderWindow
wxUpdateUIEvent event(menuid);
event.SetEventObject( this );
if ( !item || !item->IsCheckable() )
event.DisallowCheck();
bool processed = DoProcessEvent(this, event, GetWindow());
if ( !processed && senderWindow != NULL)