Ronaldo Nascimento
Ronaldo Nascimento

Reputation: 1571

What Gtk signal should I use: key-press-event or key-release-event for catching return key in a GtkEntry?

I am trying to catch the enter/return key in a GtkEntry widget. Should I make a signal hander for key-press-event or key-release event?

Upvotes: 0

Views: 2121

Answers (2)

Rob Bradford
Rob Bradford

Reputation: 1460

Alternatively you could look at connecting to the "activate" signal which gets fired when the user hits enter or activates it through some other method.

Upvotes: 4

iain
iain

Reputation: 5683

It depends when you want to act on the event as either signal will do. If you handle key-press-event and the user holds down the key, then you'll keep getting signals. If you handle key-release-event then you'll only get one signal when the user releases the key.

I think most commonly you'll want to use key-release-event.

Upvotes: 3

Related Questions