GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 23, 2014 6:42 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [GTK3 - C] GtkEntry not focus-glowing when connected
PostPosted: Thu Mar 28, 2013 2:37 am 
Offline

Joined: Tue Mar 26, 2013 9:45 pm
Posts: 2
Hello, everyone! I am having a issue with GtkEntry. When it is focused, it should glow blue. But if i connect it the way below, even if the GtkEntry is focused, it doesn't glows, and even doesn't shows the text cursor.
Code:
#include <gtk/gtk.h>

static void
on_window_focus_in  (GtkWidget *widget,
                  GdkEvent *event,
                  gpointer data)
{
}

int
main (int argc,
      char *argv[])
{
   gtk_init(&argc, & argv);
   
   GtkWidget *window;
   GtkWidget *entry;

   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width (GTK_CONTAINER(window), 8);
   g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
   

   entry = gtk_entry_new();
   gtk_container_add(GTK_CONTAINER(window), entry);
   g_signal_connect (window, "focus-in-event", G_CALLBACK(on_window_focus_in), entry); //comment this line to desactivate de bug

   gtk_widget_show_all(window);
   
   
   gtk_main ();
   
   return 0;
}


Here is screenshots:
Image

Image
In the two images the GtkEntry is focused.


Top
 Profile  
 
 Post subject: Re: [GTK3 - C] GtkEntry not focus-glowing when connected
PostPosted: Thu Mar 28, 2013 7:03 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hello and welcome,

First we do not need the full screen shot of your desktop as this makes it hard to find what it is you are talking about. It would have been better to crop the image so that we see what is needed. On my machine I had to scroll across and search around to find what you were talking about.

You are using the "focus-in-event" signal incorrectly. The signal handler should return a gboolean value and in your code you do not return anything. From the manual for the signal:-
Quote:
Returns :
TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
So in your case the most likely cause is that the return value (which could be any value due to the bug) is most likely to be TRUE. It is the other handlers that do the highlighting etc....
If you change your code to the following that should help
Code:
static gboolean
on_window_focus_in  (GtkWidget *widget,
                  GdkEvent *event,
                  gpointer data)
{
    return FALSE;
}


Also are you sure you want it to handle the whole window or just the GtkEntry?

_________________
E.


Top
 Profile  
 
 Post subject: Re: [GTK3 - C] GtkEntry not focus-glowing when connected
PostPosted: Thu Mar 28, 2013 10:04 am 
Offline

Joined: Tue Mar 26, 2013 9:45 pm
Posts: 2
Sorry about the image. My intention is to when the Window is focused (like when window cycling [ALT+TAB]) the entry becomes focused. I tried the "focus" signal, and other ones, but it didn't work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group