Re: keyboard events



I've changed the function to bool and added the "add_events(
Gdk::KEY_PRESS_MASK );" before setting the event.

I'm getting these compile errors:

(File | Line | Message)


/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h||In member
function ‘typename
sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1>::type
sigc::adaptor_functor<T_functor>::operator()(T_arg1) const [with
T_arg1 = _GdkEventKey* const&, T_functor =
sigc::bound_mem_functor1<bool, AnimeWindow, _GdkEventButton*>,
typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1>::type
= bool]’:|


/usr/include/sigc++-2.0/sigc++/functors/slot.h:137|20|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_arg1>::take) [with T_functor =
sigc::bound_mem_functor1<bool, AnimeWindow, _GdkEventButton*>,
T_return = bool, T_arg1 = _GdkEventKey*, typename
sigc::type_trait<T_arg1>::take = _GdkEventKey* const&]’|


/usr/include/sigc++-2.0/sigc++/functors/slot.h:144|45|instantiated
from ‘static void* (* sigc::internal::slot_call1<T_functor, T_return,
T_arg1>::address())(void*) [with T_functor =
sigc::bound_mem_functor1<bool, AnimeWindow, _GdkEventButton*>,
T_return = bool, T_arg1 = _GdkEventKey*, sigc::internal::hook = void*
(*)(void*)]’|


/usr/include/sigc++-2.0/sigc++/functors/slot.h:529|7|instantiated from
‘sigc::slot1<T_return, T_arg1>::slot1(const T_functor&) [with
T_functor = sigc::bound_mem_functor1<bool, AnimeWindow,
_GdkEventButton*>, T_return = bool, T_arg1 = _GdkEventKey*]’|


/usr/include/sigc++-2.0/sigc++/functors/slot.h:1157|26|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_functor1<bool, AnimeWindow,
_GdkEventButton*>, T_return = bool, T_arg1 = _GdkEventKey*]’|


/home/noobiept/Dropbox/programming/gtkmm/gtkmm_test/animeWindow.cpp:68|93|instantiated
from here|


/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h|84|error: no
match for call to ‘(sigc::bound_mem_functor1<bool, AnimeWindow,
_GdkEventButton*>) (_GdkEventKey* const&)’|


/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h|1821|note: candidate is:|


/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h|1850|note: T_return
sigc::bound_mem_functor1<T_return, T_obj, T_arg1>::operator()(typename
sigc::type_trait<T_arg1>::take) const [with T_return = bool, T_obj =
AnimeWindow, T_arg1 = _GdkEventButton*, typename
sigc::type_trait<T_arg1>::take = _GdkEventButton* const&]|


/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h|1850|note:   no
known conversion for argument 1 from ‘_GdkEventKey* const’ to
‘_GdkEventButton* const&’|


/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h|84|warning:
control reaches end of non-void function [-Wreturn-type]|


||=== Build finished: 4 errors, 1 warnings ===|


If I comment the line where I set up the event, it compiles without errors.

(Yea, I know that you can omit the 'this' part, but I sometimes still
write it, I think it makes more sense)


On Fri, Aug 26, 2011 at 2:16 AM, Mr.Cashe <mrcashe gmail com> wrote:
> 26.08.2011 06:52, lecas malecas пишет:
>
> Ok, I'm trying with the signal, but I get a lot of errors.
>
> where's what I'm doing:
>
> my class inherits from Gtk::Window.
>
> then on the constructor I have,
> this->signal_key_release_event().connect ( sigc::mem_fun(*this,
> &AnimeWindow::onKeyRelease) );
>
> (here, I don't know if I have to send an argument?..)
>
> and then my function:
>
> void AnimeWindow::onKeyRelease(GdkEventButton *event)
> {
> cout << "key" << endl;
> }
>
> On Thu, Aug 25, 2011 at 8:17 PM, Yann LEYDIER <yann leydier info> wrote:
>
> Hi,
>
> signal_key_release_event() seems the right way to do it. For the list of key
> values, see gdk/gdkkeysyms.h as stated in Gtk's documentation :
> http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventKey
>
> You could also derivate your class from Gtk::Dialog, which recieves a
> response when ESC is pressed.
>
> yann
>
> On 25/08/11 21:00, lecas malecas wrote:
>
> Hey, I have a window which I want to close when the esc key is
> pressed, I've tried overriding the "virtual bool on_key_release_event
> (GdkEventKey* event); " but I get some weird errors (also can't find
> the documentation about GdkEventKey, to identify the keys). I tried
> adding a function to the "signal_key_release_event()" but also get
> some errors :)
>
> Can anyone tell me how to call a function when the esc key is pressed
> (on a Gtk::Window derived class)?
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
> on_key_rlease_event() must return bool instead of void:
>
> bool AnimeWindow::onKeyRelease(GdkEventButton *event)
> {
> cout << "key" << endl;
> return true;
> }
>
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]