ListBox: EditCopy in an empty Edit Cell copy the whole Row

Sometimes ago, some person already stated that EditCopy is handled by the ListBox Control (where in the documentation can I reach that information ? Not in the ListBox docs page.)

So, we do not have any control on ListBox.Copy ! (When asked either with ctrl+C / cmd-c or activating the Menu).

Now, after running a project fo several hours a day (stress testings), I found something strange and I rediscover what I state above: I do not have control on the Copy process when the cursor is in a ListBox Control.

So, what I found is a bug:

In an Edited Cell, nothing is selected (in fact, the Cell is empty), from time to time, I press cmd-c in it (instead of in the above Row) to get text to paste and modify a bit) and when I Paste the Clipboard contents, I get the Row contents… (line in ListBox1.Cell(Row,-1)… Row is the Edit Cell Row #).

Shematic process to reproduce the bug:
a. The main window have one ListBox control, with many Columns / Rows
b. All Cells are Editable
c. Some Cells have contents, some don’t
d. Make an empty Cell Editable,
e. Select the EditCopy Menu (while the cursor is in the Cell and no selected Text)
d. Select the EditPaste Menu
f. You get the whole Row contents pasted into the Edit Cell.

The above is the description of a valid bug afaik.

As usual, nothing is easy here:

In the Project main window (the one where the ListBox resides), I set the Menus, Menu Bar property popup to None… Then, I run the project and discovers as strange as it seems to me that all Edit Menu Items are active.

And the bug is still present.

BTW: I checked:

No Menu Handler for any of the Edit Menus exists in App.

No, my ListBox is not a Sublass of any kind: its Super is Listbox.

Next testing: quit all applications (TExtEdit and Xojo), shutdown the computer, reboot and run Xojo only / do the same tests.

Done. Tests results: same. The bug seems to exists.

BTW: what the .xojo.uistate file do ?
Must I delete it after I got troubles ?

I stumbled across this too some time ago. I always subclass any controls and then implement the menu handlers in the subclass. That way you have complete control over Cut, Copy and Paste. The only exception I make is the EditUndo menu item, with which I never had problems, so I don’t implement this menu handler.

Thanks for your answer Eli.

In user mode:

In Edit a Cell: did you try cmd-z / ctrl-z and what are your results ?

In OS X: cmd-z never restore the text before I changed it (unfortunately, so Undo is not working).

Eli: sub-classing the ListBox to get Edit commands control back to me ? An idea.

I never allow user to edit in a listbox, I always use a dialog.

As I wrote: implement the menu handler in the listbox subclass.

Thanks Eli.

This is the first project where I can directly Edit a ListBox contents. I also show a Row view (“Record view”: display a whole Row in a single window with next / previous, etc. buttons).

I largely prefer to use in line editing (as a user).