Cannot edit content of wxTextCtrl after mouse click

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Cannot edit content of wxTextCtrl after mouse click

Post by giulio_seb »

Hello,
I am on OSX 12.2, using wxWidgets 3.1.5. I created two wxComboBoxes (on the left of this video screen capture https://streamable.com/zboz6y) and one wxTextCtrl (on the right). When I click on the wxComboBoxes with the mouse, the box gets selected and I can edit its content, but when I click on the wxTextCtrl, nothing happens, and I cannot edit its content.

Do you know what may be happening here ?

Thanks! :D :D :D
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot edit content of wxTextCtrl after mouse click

Post by ONEEYEMAN »

Hi,
How do you create the text control? Can you post some code?
Can you make a screenshot of how it all look like in your case and post it here?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot edit content of wxTextCtrl after mouse click

Post by doublemax »

Is this your first time building for OSX? Are you creating an application bundle?

https://wiki.wxwidgets.org/WxMac-specif ... ion_bundle
Use the source, Luke!
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Cannot edit content of wxTextCtrl after mouse click

Post by giulio_seb »

doublemax wrote: Tue Aug 09, 2022 5:23 pm Is this your first time building for OSX? Are you creating an application bundle?

https://wiki.wxwidgets.org/WxMac-specif ... ion_bundle
It is not the first time, and I am using Xcode. As far as I know, XCode automatically creates an application bundle, right ?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot edit content of wxTextCtrl after mouse click

Post by ONEEYEMAN »

Hi,
How do you create the control? Can you post some code?

Thank you.
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Cannot edit content of wxTextCtrl after mouse click

Post by giulio_seb »

ONEEYEMAN wrote: Tue Aug 09, 2022 3:39 pm Hi,
How do you create the text control? Can you post some code?
Can you make a screenshot of how it all look like in your case and post it here?

Thank you.
Sure, here it is. I created a ChronoField class, which is used to enter a time. In ChronoField there are two wxComboBoxes (hour, minute) and a wxTextCtrl second, which are the fields where the user will enter hours, minutes and seconds.

Code: Select all

class ChronoField{
    
public:
    //the parent frame to which this object is attached
    SightFrame* parent_frame;
    wxArrayString hours, minutes;
    //hour and minute  boxes
    wxComboBox *hour, *minute;
    //second text control
    wxTextCtrl *second;
    //texts
    wxStaticText* text_colon_1, *text_colon_2;
    wxBoxSizer *sizer_h, *sizer_v;
    Chrono* chrono;
    bool hour_ok, minute_ok, second_ok;
    CheckChrono* check;
    
    ChronoField(SightFrame*, Chrono*);
    void set(Chrono);
    void Enable(bool);
    template<class T> void get(T&);
    template<class T> void InsertIn(T*);
    bool is_ok(void);
    
};
Here is the constructor of ChronoField, which takes as inputs a SightFrame pointer (SightFrame is a class which I created, inherited from wxFrame, and a Chrono*, another class which contains the numerical values of hours, minutes and seconds)

Code: Select all

//constructor of a ChronoField object, based on the parent frame frame
ChronoField::ChronoField(SightFrame* frame, Chrono* p){
    
    unsigned int i;
    parent_frame = frame;
    chrono = p;
    
    check = new CheckChrono(this);
    //    (check.p) = this;
    
    for(hours.Clear(), hours.Add(wxT("")), i=0; i<24; i++){
        hours.Add(wxString::Format(wxT("%i"), i+1));
    }
    for(minutes.Clear(), minutes.Add(wxT("")), i=0; i<60; i++){
        minutes.Add(wxString::Format(wxT("%i"), i+1));
    }
    
    hour = new wxComboBox(parent_frame->panel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, hours, wxCB_DROPDOWN);
    hour->SetBackgroundColour(*wxWHITE);
    //    hour->SetInitialSize(hour->GetSizeFromTextSize(hour ->GetTextExtent(wxS("00"))));
    AdjustWidth(hour);
    hour->Bind(wxEVT_KILL_FOCUS, *(check->check_hour));
    
    text_colon_1 = new wxStaticText((parent_frame->panel), wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize);
    
    minute = new wxComboBox(parent_frame->panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, minutes, wxCB_DROPDOWN);
    minute->SetBackgroundColour(*wxWHITE);
    AdjustWidth(minute);
    //    minute->SetInitialSize(minute->GetSizeFromTextSize(minute->GetTextExtent(wxS("00"))));
    minute->Bind(wxEVT_KILL_FOCUS, *(check->check_minute));
    
    text_colon_2 = new wxStaticText((parent_frame->panel), wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize);
    
    second = new wxTextCtrl(parent_frame->panel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxCB_DROPDOWN);
    second->SetInitialSize(second->GetSizeFromTextSize(second->GetTextExtent(wxS(sample_width_floating_point_field))));
    second->SetBackgroundColour(*wxWHITE);
    second->Bind(wxEVT_KILL_FOCUS, *(check->check_second));
    
    
    hour->SetValue(wxString(""));
    hour_ok = false;
    
    minute->SetValue(wxString(""));
    minute_ok = false;
    
    second->SetValue(wxString(""));
    second_ok = false;
    
    sizer_h = new wxBoxSizer(wxHORIZONTAL);
    sizer_v = new wxBoxSizer(wxVERTICAL);
    
    sizer_v->Add(sizer_h, 0, wxALIGN_LEFT);
    sizer_h->Add(hour, 0, wxALIGN_CENTER);
    sizer_h->Add(text_colon_1, wxALIGN_CENTER);
    sizer_h->Add(minute, 0, wxALIGN_CENTER);
    sizer_h->Add(text_colon_2, wxALIGN_CENTER);
    sizer_h->Add(second, 0, wxALIGN_CENTER);
    
}
Finally, I insert the ChronoField object into a SightFrame in the constructor of SightFrame as follows

Code: Select all

SightFrame::SightFrame(...){
[...]
    master_clock_chrono = new ChronoField(this, &(sight->master_clock_date_and_hour.chrono));

[...]
}
Here is how it looks like https://ibb.co/rksFn88: this is a screenshot of the SightFrame, the ChronoField is circled in red, and the second wxTextCtrl in the ChronoField is cirled in green.



Thank you for your help!
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot edit content of wxTextCtrl after mouse click

Post by doublemax »

Do you call event.Skip() in the focus event handlers? If not, do so.
Use the source, Luke!
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Cannot edit content of wxTextCtrl after mouse click

Post by giulio_seb »

doublemax wrote: Fri Aug 26, 2022 6:19 pm Do you call event.Skip() in the focus event handlers? If not, do so.
I do call skip in the handlers.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot edit content of wxTextCtrl after mouse click

Post by doublemax »

giulio_seb wrote: Wed Aug 31, 2022 4:53 pm
doublemax wrote: Fri Aug 26, 2022 6:19 pm Do you call event.Skip() in the focus event handlers? If not, do so.
I do call skip in the handlers.
Then i'm out of ideas.

In any case, you should upgrade to the latest wxWidgets version 3.2.1 (or directly from GitHub).
Use the source, Luke!
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Cannot edit content of wxTextCtrl after mouse click

Post by giulio_seb »

doublemax wrote: Wed Aug 31, 2022 5:03 pm
giulio_seb wrote: Wed Aug 31, 2022 4:53 pm
doublemax wrote: Fri Aug 26, 2022 6:19 pm Do you call event.Skip() in the focus event handlers? If not, do so.
I do call skip in the handlers.
Then i'm out of ideas.

In any case, you should upgrade to the latest wxWidgets version 3.2.1 (or directly from GitHub).
Thank you, I will try the update !
Post Reply