[Mono-list] Gdk.Keyval.Name - problem (and running GNOME-apps problem as well)

Todd Berman tberman@gentoo.org
Thu, 01 Jan 2004 12:59:30 -0500


I believe a Console.WriteLine (args.Event.Key); will give you exactly
what you are looking for.

--Todd

On Thu, 2004-01-01 at 12:24, Fredrick Nilsson wrote:
> Hey!
> 
> I'm trying to retrieve the name for a key that is pressed. I'm using a
> method that looks something like this (a rough example):
> 
> 	void ButtonsPressed (object o, GtkSharp.KeyPressEventArgs args) 
> 	{
> 		Gdk.EventKey key = args.Event;
> 		string keyname = "bah";
> 		keyname = Gdk.Keyval.Name ((uint) key.keyval); 
> 		Console.WriteLine ("keyname: " + keyname);
> 	}
> 
> Unfortunately, it fails with the following error message:
> 
> Unhandled Exception: System.Reflection.TargetInvocationException:
> Exception has been thrown by the target of an invocation. --->
> System.NullReferenceException: A null value was found where an object
> instance was required
> in (unmanaged) (wrapper managed-to-native) GLibSharp.Marshaller:g_free
> (intptr)
> in <0x00004> (wrapper managed-to-native) GLibSharp.Marshaller:g_free
> (intptr)
> in <0x00025> GLibSharp.Marshaller:PtrToStringGFree (intptr)
> in <0x0002a> Gdk.Keyval:Name (uint)
> in <0x00047> .MainWindow:ButtonsPressed
> (object,GtkSharp.KeyPressEventArgs)
> in (unmanaged) /usr/lib/libmono.so.0 [0x40054ae1]
> in (unmanaged) /usr/lib/libmono.so.0(mono_runtime_invoke+0x35)
> [0x400a6e12]
> in (unmanaged) /usr/lib/libmono.so.0(mono_runtime_invoke_array+0x21b)
> [0x400a7d93]
> in (unmanaged) /usr/lib/libmono.so.0 [0x400ae2c1]
> in <0x0009c> System.Reflection.MonoMethod:Invoke
> (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
> --- End of inner exception stack trace ---
>  
> in <0x000e4> System.Reflection.MonoMethod:Invoke
> (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
> in <0x00026> System.Reflection.MethodBase:Invoke (object,object[])
> in <0x00105> System.Delegate:DynamicInvokeImpl (object[])
> in <0x00048> System.MulticastDelegate:DynamicInvokeImpl (object[])
> in <0x00011> System.Delegate:DynamicInvoke (object[])
> in <0x001e0>
> GtkSharp.boolObjectEventKeySignal:boolObjectEventKeyCallback
> (intptr,Gdk.EventKey&,int)
> in <0x00166> (wrapper native-to-managed)
> GtkSharp.boolObjectEventKeySignal:boolObjectEventKeyCallback
> (intptr,Gdk.EventKey&,int)
> in (unmanaged) (wrapper managed-to-native) Gtk.Application:gtk_main ()
> in <0x00004> (wrapper managed-to-native) Gtk.Application:gtk_main ()
> in <0x00007> Gtk.Application:Run ()
> in <0x00007> Gnome.Program:Run ()
> in <0x000b7> .Hello:Main (string[])
> 
> And I just can't see the error I'm making here. 
> 
> The other problem I have, Is that when I'm making a GNOME application, I
> always get these warnings:
> 
> (Command Key Edit:19114): GConf-CRITICAL **: file gconf-client.c: line
> 546 (gconf_client_add_dir): assertion `gconf_valid_key (dirname, NULL)'
> failed
>  
> ** (Command Key Edit:19114): WARNING **: byref boolean marshalling not
> inplemented
>  
> ** (Command Key Edit:19114): WARNING **: byref boolean marshalling not
> inplemented
> 
> This even happens when I implement a simple Hello World-application (for
> instance:
> http://go-mono.com/tutorial/gnome/bindings/gnome/hello_world.html). If I
> implement a GNOME application that uses Gnome.Program.Quit, It crashes
> and i receive the error: ** ERROR **: Must shutdown ORB from main thread
> aborting...
> 
> Anyone that has some input on the problems i experience?
> 
> BR
> .f
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list