Entering numeric input into a Gtk :: Entry widget

I'm looking for a possible method that only allows you to enter numerical input into a Gtk :: Entry widget without relying on SpinButtons. The fact is that I found a template for this ( link ), but it just won't work. I can compile it with a different code, but if I want to declare an instance with

NumericEntry<int> int_entry(1,0,10);

he tells me

expected ", or '... in front of a numeric constant

The second part is that I don’t have a clear idea of ​​how to pack this entry, because I get

cannot convert to widget

using

functionname.pack_start(int_entry())

I think there is a stupid mistake in my part (a bad combination of C ++ and Gtkmm newbie), so any help is appreciated.

+3
source share
1 answer

- Gtk:: Entry on_insert_text(). on_insert_text(), .

void NumberEntry::on_insert_text(const Glib::ustring& text, int* position)
{
    // allow only numbers to be entered
    if (contains_only_numbers(text))
        Gtk::Entry::on_insert_text(text, position);
}
+2

All Articles