|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
ColorSelectionDialogHi,
can someone please tell what's wrong with this code? [Task:File=/home/user/Projects/editor/editor/MainWindow.cs, Line=42, Column=25, Type=Error, Priority=Normal, Description=Cannot implicitly convert type `Gtk.ColorSelection' to `Gdk.Color'(CS0029)] void setColor() { colorDialog = new ColorSelectionDialog("select color"); color = new Gdk.Color(); if(colorDialog.Run()==(int)ResponseType.Ok) { color = colorDialog.ColorSelection; textview1.ModifyText(StateType.Normal,color); } } _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@... http://lists.ximian.com/mailman/listinfo/gtk-sharp-list |
|
|
Re: ColorSelectionDialogOn Mon, Jun 15, 2009 at 8:52 PM, Darwin Reynoso<monouser@...> wrote:
> Hi, > can someone please tell what's wrong with this code? > > [Task:File=/home/user/Projects/editor/editor/MainWindow.cs, Line=42, > Column=25, Type=Error, Priority=Normal, Description=Cannot implicitly > convert type `Gtk.ColorSelection' to `Gdk.Color'(CS0029)] > > void setColor() > { > colorDialog = new ColorSelectionDialog("select color"); > > color = new Gdk.Color(); > > if(colorDialog.Run()==(int)ResponseType.Ok) > { > color = colorDialog.ColorSelection; > textview1.ModifyText(StateType.Normal,color); > } > > } The correct answer to the question is: "it's in the documentation, RTFM." However, to help point you in the right direction, ColorSelectionDialog.ColorSelection returns a GTK widget that holds the Gdk.Color you are after. Also, you are not properly destroying the dialog after you use it. You should add a line right before the end of the method (outside of the if block) that reads "colorDialog.Destroy();". If you are feeling particularly paranoid about exceptions, you should wrap the block in a try/finally, like so: try { // Your method code goes here } finally { if (colorDialog != null) { colorDialog.Destroy(); colorDialog = null; } } -- Chris Howie http://www.chrishowie.com http://en.wikipedia.org/wiki/User:Crazycomputers _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@... http://lists.ximian.com/mailman/listinfo/gtk-sharp-list |
| Free embeddable forum powered by Nabble | Forum Help |