WxComboBox OnTextEnter doesn't work

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
eriX
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Feb 04, 2009 2:08 pm
Location: Germany
Contact:

WxComboBox OnTextEnter doesn't work

Post by eriX »

Ok,

I want execute my code, if the user writes a char in the WxComboBox.
I have created a new function with Events->OnTextEnter in the Form designer and wrote my code in the new function.
If I execute my programm, there happens nothing, if I enter sth. in the ComboBox.

My code works, if I set wxTE_PROCESS_ENTER to true and press enter.
But I don't want to press Enter... the function shall be startet, if I enter some text.

How can I start my function using OnTextEnter?!

Thank you very much!
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: WxComboBox OnTextEnter doesn't work

Post by catalin »

I think you're handling the wrong event type.
You probably need wxEVT_COMMAND_TEXT_UPDATED.
eriX
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Feb 04, 2009 2:08 pm
Location: Germany
Contact:

Re: WxComboBox OnTextEnter doesn't work

Post by eriX »

I added your code here:

Code: Select all

////Event Table Start
BEGIN_EVENT_TABLE(anmeldung_erfassenFrm,wxFrame)
	////Manual Code Start
	wxEVT_COMMAND_TEXT_UPDATED(ID_WXCOMBOBOX1,anmeldung_erfassenFrm::WxComboBox1TextEnter0)
	////Manual Code End

	EVT_CLOSE(anmeldung_erfassenFrm::OnClose)
But the compiler says:

Code: Select all

44 X:\Kursplaner\anmeldung_erfassenFrm.cpp `wxEVT_COMMAND_TEXT_UPDATED' cannot be used as a function
47 X:\Kursplaner\anmeldung_erfassenFrm.cpp expected `}' before "wxEventTableEntry"
47 X:\Kursplaner\anmeldung_erfassenFrm.cpp expected `,' or `;' before "wxEventTableEntry"
70 X:\Kursplaner\anmeldung_erfassenFrm.cpp expected declaration before '}' token
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: WxComboBox OnTextEnter doesn't work

Post by catalin »

Uhm.. in your initial post you mentioned wxTE_PROCESS_ENTER which is an event type.
If you want to use the event table you need to use a macro corresponding to the event type; remember "the macro" != "the event type".

The macro corresponding to wxEVT_COMMAND_TEXT_UPDATED is EVT_TEXT.
eriX
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Feb 04, 2009 2:08 pm
Location: Germany
Contact:

Re: WxComboBox OnTextEnter doesn't work

Post by eriX »

Thank you. Now the funktion is called, when the user type some text in.

Code: Select all

////Event Table Start
BEGIN_EVENT_TABLE(anmeldung_erfassenFrm,wxFrame)
	////Manual Code Start
	EVT_TEXT(ID_WXCOMBOBOX1,anmeldung_erfassenFrm::WxComboBox1TextEnter0)
	////Manual Code End

But the text, I typed in, disappeares.
Must I get the text every time and then "->SetValue();" or is there any other option that my text doesn't become deleted?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: WxComboBox OnTextEnter doesn't work

Post by catalin »

You're asking what your code does but you're not showing any of it...

You probably need to add event.Skip(). Check the docs for its purpose.
eriX
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Feb 04, 2009 2:08 pm
Location: Germany
Contact:

Re: WxComboBox OnTextEnter doesn't work

Post by eriX »

Ok, here is my code of the function, that is called when the user writes into the ComboBox:

I solved the problem that the text disappeared, if you type in sth.
Not the best way, but it works:

Code: Select all

WxComboBox1 = new wxComboBox(WxPanel1, ID_WXCOMBOBOX1, wxT(""), wxPoint(55, 200), wxSize(585, 23), arrayStringFor_WxComboBox1, 0, wxDefaultValidator, wxT("WxComboBox1"));

Code: Select all

/*
 * WxComboBox1TextEnter0
 */
void anmeldung_erfassenFrm::WxComboBox1TextEnter0(wxCommandEvent& event)
{
    // In Suchfeld eingegebenen Name erfassen:
    wxString suchstring = WxComboBox1->GetLabel();
    
	// Name in Datenbank suchen
	
    sqlite3* Datenbank;
   
    if(sqlite3_open("kursplaner.sqlite3", &Datenbank) != SQLITE_OK)
    {
        popup(1);
    }
  
    else
    {
	    char **ergebnis=NULL;
        int zeilen;
        int spalten;
        char *popup=NULL;
        
        wxString get_command = "SELECT id, name, geburtstag FROM patienten WHERE name LIKE '"+ suchstring +"%'";
        
        sqlite3_get_table(Datenbank, get_command, &ergebnis, &zeilen, &spalten, &popup);
        
        WxComboBox1->Clear();
        
        wxString temp_anzeige;
        
        if(zeilen==0)
        {
            wxMessageBox("Keine Datensätze gefunden","Kursplaner",wxOK);
        }
        else
        {
            for(int i=3; i<=zeilen*3; i+=3)
            {
                temp_anzeige="";
                temp_anzeige << ergebnis[i] << " | " << ergebnis[i+1] << " | "  << ergebnis[i+2];
                WxComboBox1->Append(temp_anzeige);
            }
        }

        WxComboBox1->SetValue(suchstring);
        WxComboBox1->SetInsertionPointEnd();

    }
    
    sqlite3_close(Datenbank);
}


I need to open the "ListBox" in the ComboBox.
Since WxWidgets 2.9.1 the is the option "->Popup();"
http://docs.wxwidgets.org/2.9.2/classwx_combo_box.html

But with the wxDevC++ 7.3.1.3 it seems that I have not the latest wxWidgets.
Is there any way to update them simply?
I only found a download for MSW installation: http://sourceforge.net/projects/wxwindows/files/2.9.2/
I installed the package in a folder, and wanted to update the "combobox.h" files only... but the compiler still don't know "->Popup();"
eriX
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Feb 04, 2009 2:08 pm
Location: Germany
Contact:

Re: WxComboBox OnTextEnter doesn't work

Post by eriX »

I couln't update WxWidgets sucessfully yet.
Is there any tutorial for updating the WxWidgets in wxDev-C++ ?
Post Reply