#include "wx/dcclient.h"
#include "wx/utils.h"
#include "wx/app.h"
- #include "wx/panel.h"
#include "wx/layout.h"
#include "wx/dialog.h"
#include "wx/frame.h"
EVT_SYS_COLOUR_CHANGED(wxWindowMSW::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindowMSW::OnInitDialog)
EVT_IDLE(wxWindowMSW::OnIdle)
- EVT_SET_FOCUS(wxWindowMSW::OnSetFocus)
END_EVENT_TABLE()
// ===========================================================================
bProcess = FALSE;
}
-#if wxUSE_BUTTON
+ // FIXME: this should be handled by
+ // wxNavigationKeyEvent handler and not here!!
else
{
- wxPanel *panel = wxDynamicCastThis(wxPanel);
- wxButton *btn = NULL;
- if ( panel )
- {
- // panel may have a default button which should
- // be activated by Enter
- btn = panel->GetDefaultItem();
- }
-
+#if wxUSE_BUTTON
+ wxButton *btn = wxDynamicCast(GetDefaultItem(),
+ wxButton);
if ( btn && btn->IsEnabled() )
{
// if we do have a default button, do press it
return TRUE;
}
- // else: but if it does not it makes sense to make
- // it work like a TAB - and that's what we do.
- // Note that Ctrl-Enter always works this way.
- }
+ else // no default button
#endif // wxUSE_BUTTON
+ {
+ // no special function for enter and don't even
+ // let IsDialogMessage() have it: it seems to
+ // do something really strange with it
+ return FALSE;
+ }
+ }
}
break;
if ( GetEventHandler()->ProcessEvent(event) )
{
-#if wxUSE_BUTTON
- wxButton *btn = wxDynamicCast(FindFocus(), wxButton);
- if ( btn )
- {
- // the button which has focus should be default
- btn->SetDefault();
- }
-#endif // wxUSE_BUTTON
-
return TRUE;
}
}
}
-#else
+#else // 0
// let ::IsDialogMessage() do almost everything and handle just the
// things it doesn't here: Ctrl-TAB for switching notebook pages
if ( msg->message == WM_KEYDOWN )
}
}
}
-#endif // 0
+#endif // 1/0
if ( ::IsDialogMessage(GetHwnd(), msg) )
{
#endif // wxUSE_ACCEL
}
+bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg)
+{
+ // preprocess all messages by default
+ return TRUE;
+}
+
// ---------------------------------------------------------------------------
// message params unpackers (different for Win16 and Win32)
// ---------------------------------------------------------------------------
// activation/focus
// ---------------------------------------------------------------------------
-void wxWindowMSW::OnSetFocus(wxFocusEvent& event)
-{
- // panel wants to track the window which was the last to have focus in it,
- // so we want to set ourselves as the window which last had focus
- //
- // notice that it's also important to do it upwards the tree becaus
- // otherwise when the top level panel gets focus, it won't set it back to
- // us, but to some other sibling
- wxWindow *win = (wxWindow *)this;
- while ( win )
- {
- wxWindow *parent = win->GetParent();
- wxPanel *panel = wxDynamicCast(parent, wxPanel);
- if ( panel )
- {
- panel->SetLastFocus(win);
- }
-
- win = parent;
- }
-
- wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
- GetClassInfo()->GetClassName(), GetHandle());
-
- event.Skip();
-}
-
bool wxWindowMSW::HandleActivate(int state,
bool WXUNUSED(minimized),
WXHWND WXUNUSED(activate))
bool wxWindowMSW::HandleSetFocus(WXHWND hwnd)
{
+ // notify the parent keeping track of focus for the kbd navigation
+ // purposes that we got it
+ wxChildFocusEvent eventFocus(this);
+ (void)GetEventHandler()->ProcessEvent(eventFocus);
+
#if wxUSE_CARET
// Deal with caret
if ( m_caret )
#if wxUSE_TEXTCTRL
// If it's a wxTextCtrl don't send the event as it will be done
- // after the control gets to process it.
- wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl);
- if ( ctrl )
+ // after the control gets to process it from EN_FOCUS handler
+ if ( wxDynamicCastThis(wxTextCtrl) )
{
return FALSE;
}
-#endif
+#endif // wxUSE_TEXTCTRL
wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
event.SetEventObject(this);