Mono, GTK, C# – Working with the clipboard (quick example)

Mono screenshot

I have a button that calls this function, grabs what’s in the clipboard and sticks it in a label. Currently it just works for text. The hard part for me was figuring out how to make an instance of the clipboard object. I thought I’d post it quickly here.

protected virtual void click (object sender, System.EventArgs e)
	Clipboard clippy = GetClipboard(Gdk.Atom.Intern("CLIPBOARD", false));
	label1.Text = clippy.WaitForText();

1 Comment

  1. Hey that’s interesting. Are you building something in particular in mono?

    Comment by Alexei — December 29, 2010 @ 2:11 pm

Sorry, the comment form is closed at this time.