How to prevent Listbox from consuming Copy?

  1. 2 weeks ago

    Tim P

    Jan 4 Pre-Release Testers feedback://46303

    I've got a Listbox on a Window and even though there's an EditCopy MenuHandler on the Window, the Listbox is consuming the copy and putting text on the pasteboard. The MenuHandler is not firing at all. While this is an easy shortcut for some uses, this destroys any kind of advanced copy functionality one may want to implement.

    Xojo 2018r4
    macOS 10.14.2 and 10.12.6

    Has anyone worked around this behavior before?

    @Tim P I've got a Listbox on a Window and even though there's an EditCopy MenuHandler on the Window, the Listbox is consuming the copy and putting text on the pasteboard. The MenuHandler is not firing at all. While this is an easy shortcut for some uses, this destroys any kind of advanced copy functionality one may want to implement.

    Xojo 2018r4
    macOS 10.14.2 and 10.12.6

    Has anyone worked around this behavior before?

    Subclass the listbox and implement the menuhandlers there

  2. Karen A

    Jan 4 Pre-Release Testers Answer

    @Tim P I've got a Listbox on a Window and even though there's an EditCopy MenuHandler on the Window, the Listbox is consuming the copy and putting text on the pasteboard. The MenuHandler is not firing at all. While this is an easy shortcut for some uses, this destroys any kind of advanced copy functionality one may want to implement.

    Xojo 2018r4
    macOS 10.14.2 and 10.12.6

    Has anyone worked around this behavior before?

    Subclass the listbox and implement the menuhandlers there

  3. Jean-Yves P

    Jan 4 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited 2 weeks ago

    if the cell is editable, the system (macos) installs a text copy-paste menu handler that bypasses any copy-paste menuhandler in the listbox.
    then you have to put the menuhandler in the window to be handled correctly.

  4. Tim P

    Jan 4 Pre-Release Testers feedback://46303

    @Karen A Subclass the listbox and implement the menuhandlers there

    The Listbox is not what holds the data being copied. It has focus because none of the other controls on the view are able to get focus. I'm expecting that the MenuHandler would fire, do you think this is a bug?

    @Jean-YvesPochez if the cell is editable, the system (macos) installs a text copy-paste menu handler that bypasses any copy-paste menuhandler in the listbox.

    The cell is not editable. You can try it out - create a brand new project, drag in a Listbox, add a few rows (no code!), and run. Edit>Copy is enabled and will copy the selected row. There is no MenuHandler on the Listbox - I may need to take Karen's approach of subclassing the Listbox to see if I can force it to do nothing.

  5. Tim P

    Jan 4 Pre-Release Testers feedback://46303

    Update: Subclassing Listbox and adding a MenuHandler did not work. The Listbox still consumed the copy and put text on the pasteboard.

  6. Tim P

    Jan 4 Pre-Release Testers feedback://46303

    Update Part 2: Instead of trying to get the Listbox to do nothing and bubble the MenuHandler up, I was able to use the MenuHandler to raise a custom event. It's a bit roundabout, but a working system.

    Thanks for your help, @Karen A and @Jean-YvesPochez !

or Sign Up to reply!