DragDrop setting SelectionData format
I am playing a little with drag and drop under gtk#. When calling
protected virtual void OnDragDataGet (object o, Gtk.DragDataGetArgs args)
{
byte[] data = GetSomeData();
args.SelectionData.Set(args.Context.Targets[0], 0, data);
}开发者_运维问答
an error occurs:
Gtk-CRITICAL **: _gtk_selection_request: assertion `(data.format >= 8) && (data.format % 8 == 0)' failed
however setting the format to 8 works fine:
protected virtual void OnDragDataGet (object o, Gtk.DragDataGetArgs args)
{
byte[] data = GetSomeData();
args.SelectionData.Set(args.Context.Targets[0], 8, data);
}
I have found some examples on drag and drop, all use 8 as the format for sending the data. (Using 0 was acually a typo.) However I have not found what this format does, or why 8 works, whereas 0 does not.
Can someone explain what "fomat" does ?
From
http://www.go-mono.com/docs/index.aspx?link=M%3aGtk.SelectionData.Set%28Gdk.Atom%2cSystem.Int32%2cSystem.Byte[]%29:
format (number of bits in a unit) - set this to 8 and encode your data as UTF-8
精彩评论