From: John O'D. <jt...@dc...> - 2009-10-23 20:42:19
|
Hi, In gtk2hs (0.10.0, with ghc 6.10.3), I'm trying to make a Paste menu item work; i.e. trying to make it paste the clipboard into a text buffer. (You can do cut, copy, paste by right clicking in the text, and then selecting the operation from the popup menu, but I'm trying to make an edit menu Paste entry do the same.) Thus I just want the menu Edit:Paste to behave the same as right click: Paste. The textBufferPasteClipboard appears to be suitable: textBufferPasteClipboard :: TextBufferClass self => self -> Clipboard clipboard - the GtkClipboard to paste from -> TextIter overrideLocation - location to insert pasted text -> Bool defaultEditable - whether the buffer is editable by default -> IO () I would have expected the third (location) argument to be of type Maybe TextIter, so you could say Nothing to get the default location (the mouse cursor), and Just iter to override it. But the type is TextIter, so it seems to be necessary to construct an Iter pointing to the default location, which should then override the default location in order to give the default location. (Sounds a bit strange!) Two questions: 1. Is there a way to do a paste simply, without the bother of making a TextIter? The other operations with the edit menu are 1-liners. 2. How can you get a TextIter to point to where the mouse cursor is? Thanks! John O'Donnell |