LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-25-2008, 05:51 AM   #1
simopal6
Member
 
Registered: Jun 2006
Location: Italy
Distribution: Slackware 13.1
Posts: 217

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:
Code:
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
BurkiPingo
LQ Newbie
 
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
Wink Solution...

Had the same problem. Here the solution :

entry=gtk_entry_new();
gtk_entry_set_activates_default(GTK_ENTRY(entry),TRUE);


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


Reply


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


All times are GMT -5. The time now is 01:58 PM.

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