Regarding GdkEventButton
- From: Jyothi <jyothi ncoretech com>
- To: gtk-list gnome org
- Subject: Regarding GdkEventButton
- Date: Tue, 18 Dec 2001 13:11:33 +0530
Hi,
I have text area and when I click on that I should get the current
cursor position. So I am using gdk_button_press event for that.
But when I click on that at some position, I get the cursor postion of
the last event. that is If I have some text of 8 letters already in
the text area, if i click at 7th position, it still gives me positon 0.
Next time I click at position 5, it gives me positon 7. that is, it is
giving the position of the cursor where it was last time . not the
current cursor position..
My code is some thing like this...
gboolean SetCursor( GtkWidget * text, GdkEventButton *event, GtkWidget
*KeyArea )
{
position = gtk_editable_get_position( GTK_EDITABLE( KeyArea ) ) ;
printf(" position = %d\n",position ) ;
}
GtkWidget * KeyArea ;
KeyArea = gtk_text_new( NULL,NULL ) ;
gtk_widget_set_usize( GTK_WIDGET( KeyArea ), 100,100 ) ;
gtk_text_set_line_wrap( GTK_TEXT( KeyArea ), 1 ) ;
gtk_text_set_word_wrap( GTK_TEXT( KeyArea ), 1 ) ;
gtk_editable_set_editable( GTK_EDITABLE( KeyArea ), TRUE ) ;
gtk_text_insert( GTK_TEXT( KeyArea ), KeyArea->style->font, NULL,
NULL, gtk_editable_get_chars( GTK_EDITABLE( Entry ), 0, -1 ), -1 ) ; /*
for copying text from the previous EDITABLE widget */
gtk_signal_connect( GTK_OBJECT( KeyArea ), "button_press_event",
GTK_SIGNAL_FUNC( SetCursor ), KeyArea ) ;
gtk_widget_set_events( KeyArea, GDK_BUTTON_PRESS_MASK ) ;
gtk_table_attach_defaults( GTK_TABLE( table ), KeyArea, 0,7,1,5 );
Thanks in advance,
Jyothi.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]