Made MSW wxSpinCtrl emit UPDATE event when validating

the value in the text field upon kill focus.
 Documented this behaviour.
 This is in line with the GTK+ control.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-09-20 14:15:14 +00:00
parent 1a27de8838
commit 1e8dba5e29
5 changed files with 38 additions and 4 deletions

View File

@@ -267,6 +267,20 @@ void wxSpinCtrl::OnSetFocus(wxFocusEvent& event)
event.Skip();
}
void wxSpinCtrl::NormalizeValue()
{
int value = GetValue();
SetValue( value );
if (value != m_oldValue)
{
wxCommandEvent event( wxEVT_COMMAND_SPINCTRL_UPDATED, GetId() );
event.SetEventObject( this );
event.SetInt( value );
GetEventHandler()->ProcessEvent( event );
m_oldValue = value;
}
}
// ----------------------------------------------------------------------------
// construction
// ----------------------------------------------------------------------------
@@ -354,6 +368,8 @@ bool wxSpinCtrl::Create(wxWindow *parent,
SetRange(min, max);
SetValue(initial);
m_oldValue = initial;
// subclass the text ctrl to be able to intercept some events
wxSetWindowUserData(GetBuddyHwnd(), this);
@@ -530,14 +546,18 @@ void wxSpinCtrl::OnSpinChange(wxSpinEvent& eventSpin)
{
wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, GetId());
event.SetEventObject(this);
event.SetInt(eventSpin.GetPosition());
(void)GetEventHandler()->ProcessEvent(event);
int value = eventSpin.GetPosition();
event.SetInt( value );
if (value != m_oldValue)
(void)GetEventHandler()->ProcessEvent(event);
if ( eventSpin.GetSkipped() )
{
event.Skip();
}
m_oldValue = value;
}
// ----------------------------------------------------------------------------