Reimplement wxPopupWindow as a WS_POPUP window under MSW
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.
This commit is contained in:
@@ -18,25 +18,28 @@
|
||||
class WXDLLIMPEXP_CORE wxPopupWindow : public wxPopupWindowBase
|
||||
{
|
||||
public:
|
||||
wxPopupWindow() { }
|
||||
wxPopupWindow() { m_owner = NULL; }
|
||||
|
||||
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
|
||||
{ (void)Create(parent, flags); }
|
||||
|
||||
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
|
||||
|
||||
virtual void SetFocus() wxOVERRIDE;
|
||||
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;
|
||||
|
||||
// get the HWND to be used as parent of this window with CreateWindow()
|
||||
virtual WXHWND MSWGetParent() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
// 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_
|
||||
|
||||
|
Reference in New Issue
Block a user