Entry completion problem
Pardon me for posting an issue while I am sure it comes from my limited knowledge. I am following the Entry completion example and it works as expected. However, I want to use a database in which entered text is being searched for similarity. I use the following code
MyApplication::MyApplication()
{
//...........
m_Entry.signal_key_release_event().connect(
sigc::mem_fun(*this,
&MyApplication::on_key_press)); // I want to sniff keyboard events
}
bool MyApplication::on_key_press(GdkEventKey *event)
{
map<id , string> searchResults;
/** This method searches for similar data and returns them back **/
find_similar_results_from_db(searchResults , m_Entry.getText().c_str());
/**My problem is here, how can I add the results to the list
**Let use the code provided in the tutorial ,
*/
auto refCompletionModel = Gtk::ListStore::create(m_Columns);
completion->set_model(refCompletionModel);
Gtk::TreeModel::Row row = *(refCompletionModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Select one";
for (const auto &pairs : map_suggestions)
{
row = *(refCompletionModel->append());
row[m_Columns.m_col_id] = pairs.first;
row[m_Columns.m_col_name] = pairs.second;
}
completion->set_text_column(m_Columns.m_col_name);
m_Entry.set_completion(completion);
}
But this does not affect completion list.
Edited by Ghost User