Don't use the child window of the desktop window for popup windows under MSW, while this worked in simplest cases, it didn't allow having functional controls inside a wxPopupWindow as e.g. wxTextCtrl didn't accept input it at all if created as a child of such window. Instead, switch to using a top-level window, with WS_POPUP style, and fix the problem with the loss of activation by explicitly pretending to still be active in the owner window when losing activation to our own popup (thanks to Barmak Shemirani for providing this solution). Also use an MSW-specific and much simpler implementation of detecting when the popup should be dismissed in wxPopupTransientWindow: instead of capturing mouse or tracking focus, just react to activation loss directly. Add a wxTextCtrl to the popup in samples/popup to show that editing it works now.
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/msw/popupwin.h
|
|
// Purpose: wxPopupWindow class for wxMSW
|
|
// Author: Vadim Zeitlin
|
|
// Modified by:
|
|
// Created: 06.01.01
|
|
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
|
// Licence: wxWindows licence
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_MSW_POPUPWIN_H_
|
|
#define _WX_MSW_POPUPWIN_H_
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// wxPopupWindow
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_CORE wxPopupWindow : public wxPopupWindowBase
|
|
{
|
|
public:
|
|
wxPopupWindow() { m_owner = NULL; }
|
|
|
|
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
|
|
{ (void)Create(parent, flags); }
|
|
|
|
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
|
|
|
|
virtual bool Show(bool show = true) wxOVERRIDE;
|
|
|
|
// return the style to be used for the popup windows
|
|
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const wxOVERRIDE;
|
|
|
|
|
|
// Implementation only from now on.
|
|
|
|
// Return the top level window parent of this popup or null.
|
|
wxWindow* MSWGetOwner() const { return m_owner; }
|
|
|
|
private:
|
|
wxWindow* m_owner;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow);
|
|
};
|
|
|
|
#endif // _WX_MSW_POPUPWIN_H_
|