Re: [gtkmm] label en button_press_event problems
- From: bart <bart hakvoort castel nl>
- To: martin-ml hippogriff de, gtkmm-list gnome org
- Subject: Re: [gtkmm] label en button_press_event problems
- Date: Fri, 10 Oct 2003 13:58:06 +0200
Thanks, it compiles now, but it doesn't seem to be working. Below is the
relevant part of my code:
--------PresenceWindow.hh---------------------------------------
class PresenceWindow : public Gtk::Window
{
Gtk::VBox vboxMain;
Gtk::Label testlabel;
public:
PresenceWindow();
bool labelklik(GdkEventButton *);
};
----------------------------------------------------------------
--------PresenceWindow.cc--------------------------------------
#include "PresenceWindow.hh"
PresenceWindow::PresenceWindow()
{
testlabel.set_text( "TEST" );
testlabel.signal_button_press_event().connect( SigC::slot(
*this,&PresenceWindow::labelklik ) );
vboxMain.pack_start( testlabel );
show_all();
}
bool PresenceWindow::labelklik( GdkEventButton* event )
{
std::cout << "LABEL --- check!!\n";
return true;
}
-------------------------------------------------------------------
Making the label sensitive makes no difference. Does anyone know what
i'm doing wrong?
thnks!
bart
On Fri, 2003-10-10 at 11:22, martin-ml hippogriff de wrote:
> Am 09.10.2003 um 21:29 Uhr haben Sie geschrieben:
> > Ok, i am trying to connect an signal_button_press_event to a
> Gtk::Label.
> > I use the following code:
> >
> > testlabel.signal_button_press_event().connect( SigC::slot(
> > &PresenceWindow::on_button_press_event ) );
>
> You need to pass a PresenceWindow object into SigC::slot().
>
> testlabel.signal_button_press_event().connect( SigC::slot(
> my_window, &PresenceWindow::on_button_press_event ) );
>
> should work if my_window is of type PresenceWindow.
>
> BUT, you must not connect on_button_press_event() to
> signal_button_press_event() or you risk entering an endless loop!
> on_button_press_event() is a virtual function that you seem to override
> correctly and that is triggered automatically if you call
> add_events(Gdk::BUTTON_PRESS) from your PresenceWindow constructor.
>
> Regards,
>
> Martin
>
>
>
>
> _______________________________________________
> 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]