Re: gtk_entry_new and accented chars
uchar= gdk_keyval_to_unicode(((GdkEventKey*)event)-keyval); tmpbuf=g_new0(gchar,7); g_unichar_to_utf8(uchar,tmpbuf); res=g_locale_from_utf8(tmpbuf,-1,NULL,NULL,NULL); In your previous message you said you want the character in Latin-1. The code above will give it in the locale's encoding (if possible), which might be something else in general. If you *know* you for some reason explicitly want Latin-1, converting from Unicode to Latin-1 is simple, just verify that the Unicode character value is less than 256 and use it as such. (Please note that many key presses *don't* correspond to any Unicode (or Latin-1, or whatever) character at all, like the shift, alt and control keys, and dead accent keys.) for char ä i get this values (((GdkEventKey*)event)-keyval = 65506 (((GdkEventKey*)event)-keyval = 65111 (((GdkEventKey*)event)-keyval = 97 Well, apparently you don't have any 'ä' key on the keyboard, and are entering the 'ä' character using a dead accent sequence. I.e. using two keystrokes, first the (dead) diaeresis key, then 'a'. Each GdkEventKey event corresponds to a physical key press or release, so you don't have any key press that would correspond to the 'ä' character as you don't have any 'ä' key on the keyboard. If you print the keyvals in hex and look them up in gdkkeysyms.h, you will see that: 65506 = 0xFFE2 = GDK_Shift_R 65111 = 0xFE57 = GDK_dead_diaeresis 97 = 0x61 = 'a' If you desperately need to get the 'ä' using a single keystroke, switch to a keyboard layout that has a 'ä' key... Also, your problem isn't exactly made easier by the fact that you apparently try to turn GDK events into emulated Windows messages. --tml ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk_entry_new and accented chars
Dear Friends I have an small app with one gtk_entry_new with an handle to my user defined key_press_event but i cannot get the accented char from latin 1 code page on entry here an part of my key handler here is the routine for key_press_event #define WM_MOVE 3 #define WM_SIZE 5 #define WM_KEYDOWN 256// 0x0100 #define WM_KEYUP257// 0x0101 #define WM_MOUSEMOVE512// 0x0200 #define WM_LBUTTONDOWN 513// 0x0201 #define WM_LBUTTONUP514// 0x0202 #define WM_LBUTTONDBLCLK515// 0x0203 #define WM_RBUTTONDOWN 516// 0x0204 #define WM_RBUTTONUP517// 0x0205 static gint cb_event( GtkWidget *widget, GdkEvent * event, gchar* data ) { gpointer gObject = g_object_get_data( (GObject*) widget, obj ); LONG lRes; if( !pSym_onEvent ) pSym_onEvent = hb_dynsymFindName( ONEVENT ); //if( !gObject ) // gObject = g_object_get_data( (GObject*) (widget-parent-parent), obj ); if( pSym_onEvent gObject ) { LONG p1, p2, p3; if( event-type == GDK_KEY_PRESS || event-type == GDK_KEY_RELEASE ) { p1 = (event-type==GDK_KEY_PRESS)? WM_KEYDOWN : WM_KEYUP; p2 = ((GdkEventKey*)event)-keyval; p3 = ( ( ((GdkEventKey*)event)-state GDK_SHIFT_MASK )? 1 : 0 ) | ( ( ((GdkEventKey*)event)-state GDK_CONTROL_MASK )? 2 : 0 ) | ( ( ((GdkEventKey*)event)-state GDK_MOD1_MASK )? 4 : 0 ); } else if( event-type == GDK_SCROLL ) { p1 = WM_KEYDOWN; p2 = ( ( (GdkEventScroll*)event )-direction == GDK_SCROLL_DOWN )? 0xFF54 : 0xFF52; p3 = 0; } else if( event-type == GDK_BUTTON_PRESS || event-type == GDK_2BUTTON_PRESS || event-type == GDK_BUTTON_RELEASE ) { p1 = (event-type==GDK_BUTTON_PRESS)? WM_LBUTTONDOWN : ( (event-type==GDK_BUTTON_RELEASE)? WM_LBUTTONUP : WM_LBUTTONDBLCLK ); p2 = 0; p3 = ( ((ULONG)(((GdkEventButton*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventButton*)event)-y)) 16 ) 0x ); } else if( event-type == GDK_MOTION_NOTIFY ) { p1 = WM_MOUSEMOVE; p2 = ( ((GdkEventMotion*)event)-state GDK_BUTTON1_MASK )? 1:0; p3 = ( ((ULONG)(((GdkEventMotion*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventMotion*)event)-y)) 16 ) 0x ); } else if( event-type == GDK_CONFIGURE ) { p2 = 0; if( widget-allocation.width != ((GdkEventConfigure*)event)-width || widget-allocation.height!= ((GdkEventConfigure*)event)-height ) { return 0; } else { p1 = WM_MOVE; p3 = ( ((GdkEventConfigure*)event)-x 0x ) | ( ( ((GdkEventConfigure*)event)-y 16 ) 0x ); } } else if( event-type == GDK_ENTER_NOTIFY || event-type == GDK_LEAVE_NOTIFY ) { p1 = WM_MOUSEMOVE; p2 = ( ((GdkEventCrossing*)event)-state GDK_BUTTON1_MASK )? 1:0 | ( event-type == GDK_ENTER_NOTIFY )? 0x10:0; p3 = ( ((ULONG)(((GdkEventCrossing*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventMotion*)event)-y)) 16 ) 0x ); } else sscanf( (char*)data,%ld %ld %ld,p1,p2,p3 ); } return 0; } any ideia? Regards Luiz ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_entry_new and accented chars
I ll change the code to get the chars on two strokes by combining then You could also approach the problem at a higher level. Instead of looking at the GDK key events, I'm pretty sure there is some GTK+ signal that you can connect to to get information about the complete characters typed. (How well that then fits together with your need to generate emulated Windows messages I can't say.) --tml ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_entry_new and accented chars
Dear Friends I have an small app with one gtk_entry_new with an handle to my user defined key_press_event but i cannot get the accented char from latin 1 code page on entry here an part of my key handler here is the routine for key_press_event #define WM_MOVE 3 #define WM_SIZE 5 #define WM_KEYDOWN 256// 0x0100 #define WM_KEYUP257// 0x0101 #define WM_MOUSEMOVE512// 0x0200 #define WM_LBUTTONDOWN 513// 0x0201 #define WM_LBUTTONUP514// 0x0202 #define WM_LBUTTONDBLCLK515// 0x0203 #define WM_RBUTTONDOWN 516// 0x0204 #define WM_RBUTTONUP517// 0x0205 static gint cb_event( GtkWidget *widget, GdkEvent * event, gchar* data ) { gpointer gObject = g_object_get_data( (GObject*) widget, obj ); LONG lRes; if( !pSym_onEvent ) pSym_onEvent = hb_dynsymFindName( ONEVENT ); //if( !gObject ) // gObject = g_object_get_data( (GObject*) (widget-parent-parent), obj ); if( pSym_onEvent gObject ) { LONG p1, p2, p3; if( event-type == GDK_KEY_PRESS || event-type == GDK_KEY_RELEASE ) { p1 = (event-type==GDK_KEY_PRESS)? WM_KEYDOWN : WM_KEYUP; p2 = ((GdkEventKey*)event)-keyval; p3 = ( ( ((GdkEventKey*)event)-state GDK_SHIFT_MASK )? 1 : 0 ) | ( ( ((GdkEventKey*)event)-state GDK_CONTROL_MASK )? 2 : 0 ) | ( ( ((GdkEventKey*)event)-state GDK_MOD1_MASK )? 4 : 0 ); } else if( event-type == GDK_SCROLL ) { p1 = WM_KEYDOWN; p2 = ( ( (GdkEventScroll*)event )-direction == GDK_SCROLL_DOWN )? 0xFF54 : 0xFF52; p3 = 0; } else if( event-type == GDK_BUTTON_PRESS || event-type == GDK_2BUTTON_PRESS || event-type == GDK_BUTTON_RELEASE ) { p1 = (event-type==GDK_BUTTON_PRESS)? WM_LBUTTONDOWN : ( (event-type==GDK_BUTTON_RELEASE)? WM_LBUTTONUP : WM_LBUTTONDBLCLK ); p2 = 0; p3 = ( ((ULONG)(((GdkEventButton*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventButton*)event)-y)) 16 ) 0x ); } else if( event-type == GDK_MOTION_NOTIFY ) { p1 = WM_MOUSEMOVE; p2 = ( ((GdkEventMotion*)event)-state GDK_BUTTON1_MASK )? 1:0; p3 = ( ((ULONG)(((GdkEventMotion*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventMotion*)event)-y)) 16 ) 0x ); } else if( event-type == GDK_CONFIGURE ) { p2 = 0; if( widget-allocation.width != ((GdkEventConfigure*)event)-width || widget-allocation.height!= ((GdkEventConfigure*)event)-height ) { return 0; } else { p1 = WM_MOVE; p3 = ( ((GdkEventConfigure*)event)-x 0x ) | ( ( ((GdkEventConfigure*)event)-y 16 ) 0x ); } } else if( event-type == GDK_ENTER_NOTIFY || event-type == GDK_LEAVE_NOTIFY ) { p1 = WM_MOUSEMOVE; p2 = ( ((GdkEventCrossing*)event)-state GDK_BUTTON1_MASK )? 1:0 | ( event-type == GDK_ENTER_NOTIFY )? 0x10:0; p3 = ( ((ULONG)(((GdkEventCrossing*)event)-x)) 0x ) | ( ( ((ULONG)(((GdkEventMotion*)event)-y)) 16 ) 0x ); } else sscanf( (char*)data,%ld %ld %ld,p1,p2,p3 ); } return 0; } any ideia? Regards Luiz ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_entry_new and accented chars
Tor for char ä i get this values (((GdkEventKey*)event)-keyval = 65506 (((GdkEventKey*)event)-keyval = 65111 (((GdkEventKey*)event)-keyval = 97 Well, apparently you don't have any 'ä' key on the keyboard, and are entering the 'ä' character using a dead accent sequence. I.e. using two keystrokes, first the (dead) diaeresis key, then 'a'. Each GdkEventKey event corresponds to a physical key press or release, so you don't have any key press that would correspond to the 'ä' character as you don't have any 'ä' key on the keyboard. If you print the keyvals in hex and look them up in gdkkeysyms.h, you will see that: 65506 = 0xFFE2 = GDK_Shift_R 65111 = 0xFE57 = GDK_dead_diaeresis 97 = 0x61 = 'a' If you desperately need to get the 'ä' using a single keystroke, switch to a keyboard layout that has a 'ä' key... Brasilian abnt2 dont have such keys, accents chars is get by using the accent key(~^´`¨) + one of the vogels so their an way to get the 'ä' key on two strokes, otherwise, ill change the code to get the chars on two strokes by combining then Also, your problem isn't exactly made easier by the fact that you apparently try to turn GDK events into emulated Windows messages. yes, since is an binding from gtk to xharbour to me compatible with the windows version,i emulate the same windows message on gtk events thanks for the answer Regards Luiz ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list