wxCalenderCtrl with wxComboCtrl poup

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Anil8753
Experienced Solver
Experienced Solver
Posts: 89
Joined: Sat Jan 16, 2016 5:57 am
Location: India

wxCalenderCtrl with wxComboCtrl poup

Post by Anil8753 » Thu Jun 18, 2020 6:21 pm

========== UPDATE =========
Issue is not with only wxCalenderCtrl, we can reproduce this issue by placing wxTextCtrl on wxComboPopup.
wxTextCtrl never gets the focus, I can not type anything.


I have a wxCancelnder control that is added to the wxComboPopup as a child.
I used UseAltPopupWindow() function just before void wxComboCtrl::SetPopupControl(wxComboPopup * popup)

Code: Select all

    
    UseAltPopupWindow();
    m_popup = new DatePickerPopup();
    SetPopupControl(m_popup);
 

Code: Select all

class DatePickerPopup : public wxPanel, public wxComboPopup
{
...
	m_calendar = new wxCalendarCtrl(this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
...
}
This works absolutely fine on Windows, but on Mac it has the focus issues.
appear-calendarctrl-mac[1].png
appear-calendarctrl-mac[1].png (10.92 KiB) Viewed 81 times
I can not select the month and year from the calendar control, like similar issue we see with wxTranseintPopupWindow.

On Windows, UseAltPopupWindow() solves the focus issues, but under mac flag set by the UseAltPopupWindow() is not used.

I checked the combocmn.cpp, I see different code is executed in case of WIndows and Mac

Code: Select all


// Create popup window and the child control
void wxComboCtrlBase::CreatePopup()
{
    wxComboPopup* popupInterface = m_popupInterface;
    wxWindow* popup;

    if ( !m_winPopup )
    {
#ifdef wxComboPopupWindowBase2
        if ( m_iFlags & wxCC_IFLAG_USE_ALT_POPUP )
        {
        #if !USES_GENERICTLW
            m_winPopup = new wxComboPopupWindowBase2( this, wxNO_BORDER );
        #else
            int tlwFlags = wxNO_BORDER;
          #ifdef wxCC_GENERIC_TLW_IS_FRAME
            tlwFlags |= wxFRAME_NO_TASKBAR;
          #endif

          #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
            m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY,
                                                      wxPoint(-21,-21), wxSize(20, 20),
                                                      tlwFlags );
          #else
            m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY, wxEmptyString,
                                                      wxPoint(-21,-21), wxSize(20, 20),
                                                      tlwFlags );
          #endif
        #endif
            m_popupWinType = SECONDARY_POPUP_TYPE;
        }
        else
#endif // wxComboPopupWindowBase2
        {
            m_winPopup = new wxComboPopupWindow( this, wxNO_BORDER );
            m_popupWinType = PRIMARY_POPUP_TYPE;
        }
        m_popupWinEvtHandler = new wxComboPopupWindowEvtHandler(this);
        m_winPopup->PushEventHandler(m_popupWinEvtHandler);
    }

    popupInterface->Create(m_winPopup);
    m_popup = popup = popupInterface->GetControl();

    m_popupEvtHandler = new wxComboPopupEvtHandler(this);
    popup->PushEventHandler( m_popupEvtHandler );

    // This may be helpful on some platforms
    //   (eg. it bypasses a wxGTK popupwindow bug where
    //    window is not initially hidden when it should be)
    m_winPopup->Hide();

    popupInterface->m_iFlags |= wxCP_IFLAG_CREATED;
}

Under Windows

Code: Select all

            m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY, wxEmptyString,
                                                      wxPoint(-21,-21), wxSize(20, 20),
                                                      tlwFlags );
                     m_popupWinType = SECONDARY_POPUP_TYPE;
 
Under Mac

Code: Select all

            m_winPopup = new wxComboPopupWindow( this, wxNO_BORDER );
            m_popupWinType = PRIMARY_POPUP_TYPE;
 
This is because of the different Macros enablement under Win and Mac
Please refer combocmn.cpp for details.

I am not sure what workaround or configuration is required to make it work.

Post Reply