Demonstrate vetoing wxEVT_SPIN_XXX events in widgets sample
Show that these events can be vetoed, which prevents the control value from changing, and also that veto doesn't apply if the event handler skips the event. See https://github.com/wxWidgets/wxWidgets/pull/1232
This commit is contained in:
parent
d9c8932188
commit
85666cd22f
@ -557,12 +557,31 @@ void SpinBtnWidgetsPage::OnSpinBtn(wxSpinEvent& event)
|
||||
|
||||
void SpinBtnWidgetsPage::OnSpinBtnUp(wxSpinEvent& event)
|
||||
{
|
||||
// Demonstrate that these events can be vetoed to prevent the control value
|
||||
// from changing.
|
||||
if ( event.GetInt() == 11 )
|
||||
{
|
||||
wxLogMessage("Spin button prevented from going up to 11 (still %d)",
|
||||
m_spinbtn->GetValue());
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
|
||||
wxLogMessage( "Spin button value incremented, will be %d (was %d)",
|
||||
event.GetInt(), m_spinbtn->GetValue() );
|
||||
}
|
||||
|
||||
void SpinBtnWidgetsPage::OnSpinBtnDown(wxSpinEvent& event)
|
||||
{
|
||||
// Also demonstrate that vetoing the event but then skipping the handler
|
||||
// doesn't actually apply the veto.
|
||||
if ( event.GetInt() == 0 )
|
||||
{
|
||||
wxLogMessage("Spin button change not effectively vetoed, will become 0");
|
||||
event.Veto();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
wxLogMessage( "Spin button value decremented, will be %d (was %d)",
|
||||
event.GetInt(), m_spinbtn->GetValue() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user