Re: problem in gtktextview
- From: "Andrew E. Makeev" <andrew solvo ru>
- To: Manoj tr <trmanoj linuxmail org>
- Cc: gtk <gtk-app-devel-list gnome org>, gtklist <gtk-list gnome org>
- Subject: Re: problem in gtktextview
- Date: Mon, 17 May 2004 06:34:22 -0000
Manoj tr wrote:
hai
I have a problem with textview. I want to replace the characters in a gtktextview after checking some condition. ie when i press "A" the displayed character will be H. But in the case of textview i enter the all code to rplace the character, but it will print both characters "AH" ie the actual one and the mapped one. I place the code bellow. any replay will very thankful to you. I want to build an editor in regional language. I think some problem in iteration. It will not correctly initialize.
With Regards
Manoj
#########################################
#include <gtk/gtk.h>
[skip]
gboolean
on_textview1_key_press_event (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
int Pos,SelPos;
gchar *fchar;
Buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW( widget)) ;
MarkCur = gtk_text_buffer_get_insert(Buf);
gtk_text_buffer_get_iter_at_mark ( Buf, &IterCur,MarkCur ) ;
gtk_text_buffer_get_iter_at_offset(Buf,&IterEnd,-1);
switch (event->keyval) {
case 65: // 'A'
First of all you have to connect key_press_event handler with option
before = TRUE, ie your function must be called before any inner GTK
handlers.
Then you have 2 options here:
1. do text insertion into textview yourself, then return TRUE to stop
event processing.
2. just replace event->keyval and return FALSE to let GTK do it's job.
gtk_text_buffer_insert( Buf,&IterCur,"H",-1);
// gtk_text_buffer_insert( Buf,&IterCur,"m",-1);
gtk_text_buffer_get_iter_at_offset(Buf,&IterEnd,gtk_text_iter_get_offset(&IterCur)-1);
//gtk_text_buffer_delete(Buf,&IterCur,&IterEnd);
break;
}
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]