Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-19-2004, 10:41 AM   #1
Registered: May 2002
Distribution: Fedora Core
Posts: 41

Rep: Reputation: 15
Gtkmm - signal_button_press_event() not sending signal?

First of all, let me hint that I am very new to Gtkmm programming, and
relatively new to C++ programming in general.

I am trying to write a simple program that draws a bezier curve in a
DrawingArea which can be manipulated by clicking and dragging its
control points.

Right now the program draws a curve, but I have not yet successfully
implemented anything to manipulate it. That's what I'm working on.

I figured I'd start by figuring out how to detect a button click on the
DrawingArea. I know I'll need to get the coordinates of the mouse
pointer as well. From reading the tutorial, etc. it seemed that
Widget::signal_button_press_event() is the appropriate method to use. I
have connected it to a signal handler in my MainWindow class.
Everything compiles fine but the code in my signal handler doesn't seem
to execute.

Here's what code it seems you'd need.
In MainWindow's constructor (curveArea is my DrawingArea):
A protected member of MainWindow:
bool MainWindow::on_curve_button_press_event(GdkEventButton* event)
        std::cout << "The drawing area was clicked" << std::endl;

        return true;
I searched the web for a while trying to find any hints, and was only
able to find something on a mailing list from 2002 that said it was a
bug. Seems like that wouldn't be relevant anymore. Any help would be
greatly appreciated. If you want all my source code, let me know.

Lastly, my development environment:

Fedora Core 3
gcc 3.4.2
gtk 2.4.14
glib 2.4.8
libsigc++ 2.0.6
glibmm 2.4.5
gtkmm 2.4.8

Matthew Hurne
Old 12-19-2004, 02:38 PM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
Don't know if gtkmm is much different at this place than pure gtk (that's what I use), but I use that sequence (modified, of course):
gtk_signal_connect (GTK_OBJECT (drawingArea),
     "button_press_event", (GtkSignalFunc) drawing_button_press_event, NULL);
gtk_widget_set_events (drawingArea,
So I do not only connect the signal but also use *set_events. Remember that drawingArea is different than other widgets at many points.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending signal from one host to other zaheer031 Linux - Networking 1 11-04-2004 12:31 PM
Sending a signal to a process (Help me) rajesh_b Programming 2 09-17-2004 01:30 AM
Does sending processes the 9 signal, or restarting the X server cause damage? Squall Linux - General 1 06-07-2004 10:14 AM
sending signal to thread waiting on pselect exedx Programming 4 03-21-2004 11:48 PM
INIT: Sending processes the TERM signal vicente Linux - Software 2 10-02-2001 08:35 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration