Click to place cursor problem



To: gtk-app-devel-list gnome org
Subject: Click to place cursor problem

Hello,

I am having a problem using GtkTextView with GtkScrolledWindow. When I click to place the cursor, text is selected instead. The problem only occurs at application startup.

Thanks,
Mark

Steps to reproduce the problem:
1) Startup application, the cursor should not be visible since it is at the end of the buffer. 2) Using the scrollbar, scroll to an arbitrary location except the very end of the buffer.
3) Click on the screen to place the cursor.

Results:
Text is selected instead of placing the cursor. The length of the selection is dependent on the scroll distance to the cursor (initialy at the end of the buffer).

Other things to try:
1) Instead of single clicking, click and hold the mouse button.
2) Instead of clicking the mouse, type a character on the keyboard. The view will jump to the end of the buffer. This is correct behavior.

Note:
The same problem occures if I manually set the cursor using gtk_text_buffer_place_cursor() to the top of the buffer, scroll down to the bottom of the buffer with the scrollbar and click to place the cursor.

Conclusion:
It appears the the first mouse click is being interpreted as a key press.

OS:
Stock RH7.2

RPMs:
atk-1.0.1-1gtk.i386.rpm
atk-devel-1.0.1-1gtk.i386.rpm
freetype-2.0.9-2gtk.i386.rpm
freetype-devel-2.0.9-2gtk.i386.rpm
glib2-2.0.1-1gtk.i386.rpm
glib2-devel-2.0.1-1gtk.i386.rpm
pango-1.0.1-1gtk.i386.rpm
pango-devel-1.0.1-1gtk.i386.rpm
pkgconfig-0.12.0-1gtk.i386.rpm


Code Example:

#include <gtk/gtk.h>


/* Add some text to our text widget */

void insert_text (GtkTextBuffer *buffer)
{
  GtkTextIter iter;

  gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);

  gtk_text_buffer_insert (buffer, &iter,
   "From: pathfinder nasa gov\n"
   "To: mom nasa gov\n"
   "Subject: Made it!\n"
   "\n"
   "We just got in this morning. The weather has been\n"
   "great - clear but cold, and there are lots of fun sights.\n"
   "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   "Sojourner says hi. See you soon.\n"
   " -Path\n", -1);
}

/* Create a scrolled text area that displays a "message" */
GtkWidget *create_text( void )
{
  GtkWidget *scrolled_window;
  GtkWidget *view;
  GtkTextBuffer *buffer;

  view = gtk_text_view_new ();
gtk_widget_modify_font (view, pango_font_description_from_string ("Fixed 14"));
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 5);

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
  insert_text (buffer);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_container_add (GTK_CONTAINER (scrolled_window), view);

  gtk_widget_show_all (scrolled_window);

  return scrolled_window;
}

int main( int   argc, char *argv[] )
{
   GtkWidget *window;
   GtkWidget *text;


   gtk_init (&argc, &argv);

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
   gtk_container_set_border_width (GTK_CONTAINER (window), 0);
   gtk_widget_set_size_request (GTK_WIDGET (window), 450, 400);

   text = create_text ();
   gtk_container_add (GTK_CONTAINER (window), text);

   gtk_widget_show_all (window);

   gtk_main ();

   return 0;
}


Compiler:
gcc text.c -o text `pkg-config gtk+-2.0 --cflags --libs`



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]