Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 01-25-2008, 05:51 AM   #1
Registered: Jun 2006
Location: Italy
Distribution: Slackware 13.1
Posts: 218

Rep: Reputation: 30
GTK message dialog, problem with default response

Hello, I've got a GtkMessageDialog with a text field and two buttons (OK and CANCEL).
I need to set the OK button as the default response when the user presses the "Enter" key.

This is what I've tried:
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK_CANCEL, text);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
The problem is that this doesn't work correctly. If the focus is not the text field, pressing "enter" doesn't do anything. However, when the focus is removed from the text field, pressing "enter" closes the window and sends the GTK_RESPONSE_OK response.

What can I do in order to have the "enter" key close the window even when the text field has the focus?

Thank you!
Old 03-22-2012, 03:26 AM   #2
LQ Newbie
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
Wink Solution...

Had the same problem. Here the solution :


The the entry sends the ENTER key event to your default element


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
System message into the dialog dimah Programming 1 05-22-2006 09:21 AM
'dialog' app for GTK+2.0 General Programming 6 04-23-2006 01:10 PM
Dialog modal+GTK santhosh.linux Programming 1 02-20-2006 11:47 AM
GTK 2.0 problems in displaying dialog boxes stephenwalter Programming 1 01-20-2006 01:21 AM
Problem: Default Login Manager &Logout Dialog Ray2047 Debian 6 12-24-2005 07:33 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 AM.

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