Mayank Prabhakar
Mayank Prabhakar

Reputation: 133

How to make a Widget clickable

I have made a table using GtkTable and in that table I have attached widget in linux.

On each widget a video is displaying. Now I want to make all widgets click-able so I will be able to display clicked video in full screen mode.

What function should be used for making widget click-able.

Upvotes: 0

Views: 358

Answers (2)

Tiger Soldier
Tiger Soldier

Reputation: 361

No idea what child widget you are using. Many widgets emits the signal button-release-event when the mouse clicks (press then release) on it. You can listen to the signal like this:

gboolean toggle_play(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
    // play or pause the video of the widget
    return TRUE; // or FALSE if you connected more than one handlers to this signal
}

g_signal_connect(widget, "button-release", G_CALLBACK (toggle_play), data);

where widget is your child widget to play videos, it will be passed as the first argument of toggle_play. data is additional data to be passed as the third argument of toggle_play, which can be simply NULL if not needed.

You may need to add GDK_BUTTON_RELEASE_MASK to the event mask of child widgets:

gtk_widget_add_events (widget, GDK_BUTTON_RELEASE_MASK);

Upvotes: 1

mikithskegg
mikithskegg

Reputation: 816

Maybe widget GtkEventBox will help you.

Upvotes: 1

Related Questions