GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Nov 23, 2014 5:11 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GtkTextView + focus-in-event signal issue
PostPosted: Fri Feb 10, 2012 9:42 am 
Offline

Joined: Thu Feb 09, 2012 3:55 pm
Posts: 2
Hello everyone!
I am new here so I will say some words about me. I am from Brazil and I work in a company who make automated machines to metalurgical industries.
We have a HMI that runs Linux and the software is based on GTK and C.
I am facing an issue since Wednesday.
Our HMI doesn't have a keyboard so I did it in GTK. When the user selects a GtkEntry or a GtkTextView, a Virtual Keyboard is showed then user can type a text.
I am using a GtkNotebook where each page is a screen. If I change the page, another screen is showed to user.
I use the signal focus-in-event on GtkEntry and GtkTextView widgets to control when to show the Virtual Keyboard.
It is working very well for GtkEntry but if I try to show the VirtualKeyboard from a GtkTextView it doesn't work. The Virtual Keyboard page is selected correctly but the focus remains on GtkTextView. I've tried to use gtk_widget_grab_focus to set focus to a widget but no success.
If I press ALT+TAB to go to another application then press ALT+TAB again, the focus goes to the VirtualKeyboard page and all works fine.
If I use another signal like key-press-event, it works for both GtkEntry and GtkTextView without any problem.
I changed my program to have only what is needed to show this issue. Please see attached .tgz archive containing .c and .glade files for better understanding. There is a compilation script too.
Any comments will be highly appreciated.
Thanks in advance!

Best regards,
Marcelo Utikawa da Fonseca


Attachments:
File comment: Archive with .c, .glade and a shell script
focus.tgz [3.11 KiB]
Downloaded 51 times
Top
 Profile  
 
 Post subject: Re: GtkTextView + focus-in-event signal issue
PostPosted: Mon Feb 13, 2012 10:21 am 
Offline

Joined: Thu Feb 09, 2012 3:55 pm
Posts: 2
Hi everybody!

I am keeping trying to know what could be wrong with my code. Now I have a "workaround" for the issue but with an inconvenient: I loose the first widget clicked in the Virtual Keyboard.
After further investigations I realize that , after to open Virtual Keyboard, a widget of it (in my case, OK button) has the focus. When I click on any widget, the focus comes back to GtkTextView in another page of GtkNotebook (should it be a bug?) then I have no more control on any widget in Virtual Keyboard. When I press ALT+TAB, the GtkTextView loose its focus. When I press ALT+TAB again and return to my application, GtkTextView grab focus again but, this time, if I click on any widget of Virtual Keyboard, GtkTextView lose the focus and the clicked widget get it. After to confirm this behaviour I changed my code to transfer the focus to Virtual Keyboard if GtkTextView grab the focus and Virtual Keyboard page is selected.
Follow my workaround just for reference:
Code:
gboolean cbFocusIn(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
  GtkNotebook *ntb = GTK_NOTEBOOK(gtk_builder_get_object(builder, "ntbWorkArea"));

  if(gtk_notebook_get_current_page(ntb)) {
    gtk_notebook_set_current_page(ntb, 0);
  } else {
    gtk_widget_grab_focus(GTK_WIDGET(gtk_builder_get_object(builder, "txvVirtualKeyboard")));
  }

  return FALSE;
}


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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