Re: Gtk::Entry and signal_key_press_event
- From: Krzesimir Nowak <qdlacz gmail com>
- To: Andreas Bauer <baueran rsise anu edu au>
- Cc: gtkmm-list gnome org
- Subject: Re: Gtk::Entry and signal_key_press_event
- Date: Mon, 06 Apr 2009 10:51:45 +0200
On Sun, 2009-04-05 at 14:04 +1000, Andreas Bauer wrote:
> Dear all,
>
> I have a very simple to describe problem with gtkmm 2.4. I have a
> small window using a Gtk::Entry:
>
> class NewWorldWin : public Gtk::Window
> {
> ...
> Gtk::Entry name_entry;
> };
>
> And I am trying to be notified of users typing in that entry, hence in
> the implementation I have added:
>
> NewWorldWin::NewWorldWin(void)
> {
> ...
>
> name_entry.
> signal_key_press_event().
> connect(sigc::mem_fun(*this, &NewWorldWin::some_handler));
> }
>
> However, I cannot get it past the compiler. Here's the error I am
> getting, which, unfortunately, does not point at my code but at the
> internals of libsigc++. I am a bit lost, how to interpret it.
>
> /usr/include/sigc++-2.0/sigc++/functors/slot.h: In static member function `static T_return sigc::internal::slot_call1<T_functor, T_return, T_arg1>::call_it(sigc::internal::slot_rep*, typename sigc::type_trait<T_arg3>::take) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]':
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:144: instantiated from `static void* (* sigc::internal::slot_call1<T_functor, T_return, T_arg1>::address())(void*) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:529: instantiated from `sigc::slot1<T_return, T_arg1>::slot1(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:1157: instantiated from `sigc::slot<T_return, T_arg1, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> newworldwin.cc:58: instantiated from here
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:137: error: void value not ignored as it ought to be
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member function `typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, void, void, void, void, void, void>::type sigc::adaptor_functor<T_functor>::operator()(T_arg1) const [with T_arg1 = GdkEventKey* const&, T_functor = sigc::bound_mem_functor0<void, NewWorldWin>]':
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:137: instantiated from `static T_return sigc::internal::slot_call1<T_functor, T_return, T_arg1>::call_it(sigc::internal::slot_rep*, typename sigc::type_trait<T_arg3>::take) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:144: instantiated from `static void* (* sigc::internal::slot_call1<T_functor, T_return, T_arg1>::address())(void*) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:529: instantiated from `sigc::slot1<T_return, T_arg1>::slot1(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:1157: instantiated from `sigc::slot<T_return, T_arg1, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, NewWorldWin>, T_return = bool, T_arg1 = GdkEventKey*]'
> newworldwin.cc:58: instantiated from here
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84: error: no match for call to `(sigc::bound_mem_functor0<void, NewWorldWin>) (GdkEventKey* const&)'
> /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1786: note: candidates are: T_return sigc::bound_mem_functor0<T_return, T_obj>::operator()() const [with T_return = void, T_obj = NewWorldWin]
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84: error: return-statement with a value, in function returning 'void'
> make: *** [all] Error 1
>
> Any pointers on what I am doing wrong? I feel, I am missing something
> obvious, but not obvious enough such that the compiler would complain
> about MY code.
>
> By the way, I have also tried to inherit from Gtk::Entry and override
> on_key_press_event, which works fine but then I cannot access the data
> of my window, and my design becomes generally 'ugly'. So I'd like to
> somehow have access to that signal inside the window rather than write
> my own Entry-derivate, and split off a dedicated data class.
>
> Many thanks for any help in advance,
>
> Andreas.
>
I'm shooting - maybe your some_handler should return a bool instead of
void. You didn't show a prototype of your some_handler.
signal_key_press_event:
http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Widget.html#5d011cc0cfa3993bc342ccff612c13ff
Krzesimir Nowak
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]