Defer using of editable check box in wxPG until it is fully initialized.
Currently, when wxPGCheckBoxEditor is clicked then associated check box (wxSimpleCheckBox) is created and immediately after that its state is changed. This causes problems when underlaying validation is performed because the check box object is not yet registered as an active editor and thus it is not visible from within e.g. validation function. We need to defer changing the initial state of the check box until this box is registered by queuing the special event which will be processed after initialization. Closes #16361. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1500,18 +1500,22 @@ private:
|
||||
Refresh();
|
||||
event.Skip();
|
||||
}
|
||||
void OnLeftClickActivate( wxCommandEvent& evt );
|
||||
|
||||
static wxBitmap* ms_doubleBuffer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
wxDEFINE_EVENT( wxEVT_CB_LEFT_CLICK_ACTIVATE, wxCommandEvent );
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSimpleCheckBox, wxControl)
|
||||
EVT_PAINT(wxSimpleCheckBox::OnPaint)
|
||||
EVT_LEFT_DOWN(wxSimpleCheckBox::OnLeftClick)
|
||||
EVT_LEFT_DCLICK(wxSimpleCheckBox::OnLeftClick)
|
||||
EVT_KEY_DOWN(wxSimpleCheckBox::OnKeyDown)
|
||||
EVT_SIZE(wxSimpleCheckBox::OnResize)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_CB_LEFT_CLICK_ACTIVATE, wxSimpleCheckBox::OnLeftClickActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSimpleCheckBox::~wxSimpleCheckBox()
|
||||
@@ -1585,6 +1589,15 @@ void wxSimpleCheckBox::SetValue( int value )
|
||||
propGrid->HandleCustomEditorEvent(evt);
|
||||
}
|
||||
|
||||
void wxSimpleCheckBox::OnLeftClickActivate( wxCommandEvent& evt )
|
||||
{
|
||||
// Construct mouse pseudo-event for initial mouse click
|
||||
wxMouseEvent mouseEvt(wxEVT_LEFT_DOWN);
|
||||
mouseEvt.m_x = evt.GetInt();
|
||||
mouseEvt.m_y = evt.GetExtraLong();
|
||||
OnLeftClick(mouseEvt);
|
||||
}
|
||||
|
||||
wxPGWindowList wxPGCheckBoxEditor::CreateControls( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
@@ -1607,22 +1620,15 @@ wxPGWindowList wxPGCheckBoxEditor::CreateControls( wxPropertyGrid* propGrid,
|
||||
|
||||
if ( !property->IsValueUnspecified() )
|
||||
{
|
||||
// If mouse cursor was on the item, toggle the value now.
|
||||
if ( propGrid->GetInternalFlags() & wxPG_FL_ACTIVATION_BY_CLICK )
|
||||
{
|
||||
// Send the event to toggle the value (if mouse cursor is on the item)
|
||||
wxPoint point = cb->ScreenToClient(::wxGetMousePosition());
|
||||
if ( point.x <= (wxPG_XBEFORETEXT-2+cb->m_boxHeight) )
|
||||
{
|
||||
if ( cb->m_state & wxSCB_STATE_CHECKED )
|
||||
cb->m_state &= ~wxSCB_STATE_CHECKED;
|
||||
else
|
||||
cb->m_state |= wxSCB_STATE_CHECKED;
|
||||
|
||||
// Makes sure wxPG_EVT_CHANGING etc. is sent for this initial
|
||||
// click
|
||||
propGrid->ChangePropertyValue(property,
|
||||
wxPGVariant_Bool(cb->m_state));
|
||||
}
|
||||
wxCommandEvent *evt = new wxCommandEvent(wxEVT_CB_LEFT_CLICK_ACTIVATE, cb->GetId());
|
||||
// Store mouse pointer position
|
||||
evt->SetInt(point.x);
|
||||
evt->SetExtraLong(point.y);
|
||||
wxQueueEvent(cb, evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user