From 42dc2a0fc6521643f1e91bca83b8507674f1da0c Mon Sep 17 00:00:00 2001 From: daleclack Date: Thu, 11 Jan 2024 19:12:29 +0800 Subject: [PATCH] The model for dropdown should has no selection --- Gtkmm4/gtk157_editlist/src/MainWin.cc | 8 +++++--- Gtkmm4/gtk157_editlist/src/MainWin.hh | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gtkmm4/gtk157_editlist/src/MainWin.cc b/Gtkmm4/gtk157_editlist/src/MainWin.cc index 9777a13..372e6f0 100644 --- a/Gtkmm4/gtk157_editlist/src/MainWin.cc +++ b/Gtkmm4/gtk157_editlist/src/MainWin.cc @@ -22,7 +22,9 @@ MainWin::MainWin() // Create List for column View main_list = Gio::ListStore::create(); - selection = Gtk::SingleSelection::create(main_list); + + // The list for dropdown to select should has no selection + selection = Gtk::NoSelection::create(main_list); main_column_view.set_model(selection); // Add items @@ -162,13 +164,13 @@ void MainWin::bind_version(const Glib::RefPtr &item) void MainWin::btnadd_clicked() { // Append a item to the list - main_list->append(ModelColumns::create(" ", " ")); + main_list->append(ModelColumns::create("", "")); } void MainWin::btnremove_clicked() { // Get Position of item - auto pos = selection->get_selected(); + auto pos = main_list->get_n_items() - 1; // Remove item main_list->remove(pos); diff --git a/Gtkmm4/gtk157_editlist/src/MainWin.hh b/Gtkmm4/gtk157_editlist/src/MainWin.hh index 07f1df0..33b1c44 100644 --- a/Gtkmm4/gtk157_editlist/src/MainWin.hh +++ b/Gtkmm4/gtk157_editlist/src/MainWin.hh @@ -69,7 +69,7 @@ public: private: // Main list object for branchs and versions Glib::RefPtr> main_list; - Glib::RefPtr selection; + Glib::RefPtr selection; // Factory to renderer string for dropdown Glib::RefPtr drop_factory;