Send correct event directly from wxGenericColourButton
Instead of sending wxEVT_COLOURPICKER_CHANGED event from the button itself and then catching it in wxColourPickerCtrl and resending an event from the control from there, just send the event originating from the correct object directly. This allows to slightly simplify the code and will be especially useful for other events, to be added in the upcoming commits, to avoid having to write the same forwarding code for all of them.
This commit is contained in:
@@ -129,10 +129,7 @@ void wxColourPickerCtrl::OnColourChange(wxColourPickerEvent &ev)
|
||||
{
|
||||
UpdateTextCtrlFromPicker();
|
||||
|
||||
// the wxColourPickerWidget sent us a colour-change notification.
|
||||
// forward this event to our parent
|
||||
wxColourPickerEvent event(this, GetId(), ev.GetColour());
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
#endif // wxUSE_COLOURPICKERCTRL
|
||||
|
@@ -91,9 +91,13 @@ void wxGenericColourButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
||||
ms_data = dlg.GetColourData();
|
||||
SetColour(ms_data.GetColour());
|
||||
|
||||
// fire an event
|
||||
wxColourPickerEvent event(this, GetId(), m_colour);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
// Fire the corresponding event: note that we want it to appear as
|
||||
// originating from our parent, which is the user-visible window, and not
|
||||
// this button itself, which is just an implementation detail.
|
||||
wxWindow* const parent = GetParent();
|
||||
wxColourPickerEvent event(parent, parent->GetId(), m_colour);
|
||||
|
||||
ProcessWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -50,8 +50,11 @@ static void gtk_clrbutton_setcolor_callback(GtkColorButton *widget,
|
||||
#endif
|
||||
p->GTKSetColour(gdkColor);
|
||||
|
||||
// fire the colour-changed event
|
||||
wxColourPickerEvent event(p, p->GetId(), p->GetColour());
|
||||
// Fire the corresponding event: note that we want it to appear as
|
||||
// originating from our parent, which is the user-visible window, and not
|
||||
// this button itself, which is just an implementation detail.
|
||||
wxWindow* const parent = p->GetParent();
|
||||
wxColourPickerEvent event(parent, parent->GetId(), p->GetColour());
|
||||
p->HandleWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user