Trap text pasted into ActiveCell of ListBox

I noticed that if I subclass a ListBox and add a EditPaste menu handler on it, this traps a paste to the listbox, but not when a cell is active. Is there a way to trap the text that is pasted into an active cell?

Thanks in advance,

Mark

This was discussed 2 or 3 weeks ago but someone removed the thread which should be here
https://forum.xojo.com/26890-intercept-paste-handler-from-an-editable-cell :frowning:
google has a cache of the start of it
http://webcache.googleusercontent.com/search?q=cache:TBybJVuyGTsJ:https://forum.xojo.com/26890-intercept-paste-handler-from-an-editable-cell+&cd=1&hl=en&ct=clnk&gl=us&client=safari

Many strategies were offered, of the ones that worked the easiest was like this…

[code]Property toggledPasteMenu As MenuItem

//Listbox events
Sub Open()
toggledPasteMenu = EditPaste
End Sub

Sub CellGotFocus(row as Integer, column as Integer)
toggledPasteMenu.Name = “EditPasteSpecial”
End Sub

Sub CellLostFocus(row as Integer, column as Integer)
toggledPasteMenu.Name = “EditPaste”
End Sub

//MenuHandlers
Function EditPaste() As Boolean
MsgBox “regular paste”
Return True
End Function

Function EditPasteSpecial() As Boolean
MsgBox “special paste”
Return True
End Function[/code]

Basically when the ActiveCell is showing there’s a tight internal hook that bypasses all the normal event activity. What jean-yves discovered is you can ‘change the name’ of the EditPaste Menuitem. When the name is changed that internal hook doesn’t capture anymore, but a menu handler for the new name will.

The trick is to first store the EditPaste Menuitem into a property reference because once you change the name you can’t refer to it by name anymore.

[quote=229981:@Will Shank]This was discussed 2 or 3 weeks ago but someone removed the thread which should be here
https://forum.xojo.com/26890-intercept-paste-handler-from-an-editable-cell :(.[/quote]
That conversation is still there
It IS however listed in Xojo Pro (not sure why)

I can’t see it anymore. ?!

Hi Will,

Many thanks for taking the time to reply. I tried this but when I paste in an active cell the Command-V isn’t caught - as in the ‘EditPasteSpecial’ menu handler isn’t called. The app beeps as though it’s rejecting the entry of the keystrokes directly into the cell. I see in the Edit Menu that the Paste menuitem is greyed out when a cell is active. Should it do this? The regular paste (when a cell is not active) works fine.

Regards,

Mark

Sorry my bad. I had placed the CellGotFocus, CellLostFocus and Menu handlers into the ListBox subclass. With the event handlers in the ListBox and the two Menu Handlers in the window all works great. Thanks

No idea why but your account isn’t marked Xojo Pro
Customer service might be able to help

I’m not Pro, so the conversation must’ve started publicly and flipped channels.

No idea