Cannot edit content of wxTextCtrl after mouse click
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Cannot edit content of wxTextCtrl after mouse click
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!
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!
Re: Cannot edit content of wxTextCtrl after mouse click
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.
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.
Re: Cannot edit content of wxTextCtrl after mouse click
Is this your first time building for OSX? Are you creating an application bundle?
https://wiki.wxwidgets.org/WxMac-specif ... ion_bundle
https://wiki.wxwidgets.org/WxMac-specif ... ion_bundle
Use the source, Luke!
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Cannot edit content of wxTextCtrl after mouse click
It is not the first time, and I am using Xcode. As far as I know, XCode automatically creates an application bundle, right ?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
Re: Cannot edit content of wxTextCtrl after mouse click
Hi,
How do you create the control? Can you post some code?
Thank you.
How do you create the control? Can you post some code?
Thank you.
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Cannot edit content of wxTextCtrl after mouse click
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);
};
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);
}
Code: Select all
SightFrame::SightFrame(...){
[...]
master_clock_chrono = new ChronoField(this, &(sight->master_clock_date_and_hour.chrono));
[...]
}
Thank you for your help!
Re: Cannot edit content of wxTextCtrl after mouse click
Do you call event.Skip() in the focus event handlers? If not, do so.
Use the source, Luke!
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Cannot edit content of wxTextCtrl after mouse click
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!
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Cannot edit content of wxTextCtrl after mouse click
Thank you, I will try the update !doublemax wrote: ↑Wed Aug 31, 2022 5:03 pmThen i'm out of ideas.
In any case, you should upgrade to the latest wxWidgets version 3.2.1 (or directly from GitHub).