Listbox cell editing does not persist

I have a listbox whose cells I want to be editable, so in the CellClick event I have:

    me.ColumnTypeAt(column) = ListBox.CellTypes.TextField
    me.ActiveTextControl.AllowSpellChecking = false

Click once on a row and it’s selected, click again and the cell becomes editable with all text selected. So far so good.
Often, and for no apparent reason, the editable state of the cell simply disappears after a quarter of a second or so. So when I click (a second time) on a cell to edit its text, the text is selected in blue, then a quarter second later the cell turns gray and the editing is cancelled, and the text cannot be altered.

Sometimes switching apps or going to another document window that my app has open, then returning to the original document, cancels this anomaly, sometimes not. Of course this is very irritating because it defeats the ability to enter data into a cell.

I have various timers running in my app that I believe I disabled, and this happens in a simple dummy listbox I created alongside my “main” one, and this behavior appears to be triggered document- or even app-wide.

Before I start chasing a ghost, has anyone experienced this problem with listboxes?
Xojo 2020r1 on Mac.

Thanks for any thoughts

why not in Open Event ?

That’s what I had initially, and when I saw this anomalous behavior, I though I had it wrong and went along with what the LR recommends:

I use double click in a Cell to Edit (all ListBox Cells are editable) and do not have any problem with that for many years.

I like your idea: I will change to dblClick to open a cell for editing (BTW: I can’t but wonder why we don’t get the row,column in the DoubleClick event…).
Somehow tho I get the feeling that the “spontaneous closure of editing” issue is unrelated, but I will try and see.
Thx for the suggestion Emile, I like it.

The DoubleClick Event (below) is populated with Xojo LR Code:

Sub DoubleClick() Handles DoubleClick
  Dim row, column As Integer
  row    = Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
  column = Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
  // Set the Cell to Editable
  Me.CellType(row, column) = ListBox.TypeEditable
  Me.EditCell(row, column)
End Sub

BUT: the Edited Cell disappears if you go outside of the running application / project. You have to add code to save / re Edit the cell (apparently, I’ve done the Edit Back at Window Activate time).

Sub Activate() Handles Activate
  // Set the Row, Column to Editable
  LB.CellType(Edited_Row, Edited_Column) = ListBox.TypeEditable
  LB.EditCell(Edited_Row, Edited_Column)
End Sub

Edited_Row, Edited_Column are Integer Properties set at DoubleClick Event time.

Thx Emile, in fact that’s what I do (subclass listbox and create my own DoubleClick event that relies on x,y at first mouseDown, then computes row,col from that; I still think Xojo should pass us that in the built-in DoubleClick event).

Now back to my original problem: as I suspected, your dblClick-to-edit idea did not solve the problem (tho I changed my code to open editing like that, because I like it better, thx for that). My problem was a GUI update timer running in another window. The odd part is the “other window” was an implicit instance of my main doc window, that is supposed to be visible = false (in which case the GUI timer is stopped), and in fact cannot be seen, but when I tested self.visible it returned true even tho this instance was nowhere to be seen. This I don’t get at all.

Listbox cell editing is not persistant by itself.

You have to code it or once your window goes out of front, the ListBox Cell left the Editing mode…

For sure, except my window remained frontmost and the cell editing closed by itself after quarter second or so, making it impossible to edit its contents.
Anyway, now I know why, but I still don’t understand how an implicit instance of a window whose visible=true is in fact hidden.

Have-you looked at the Activate Event (read above) ?

Yes, but to be clear, my issue was:

  1. in frontmost window, make a cell editable
  2. in same frontmost window, a quarter second later, cell closes for editing spontaneously, whether I opened for editing in code, as above, or not

Did you checked the LostFocus / GetFocus Events ?

If they fired, you can reset the Cell Edit Mode there…

i’m sure they fired, because of the rogue timer, and if I reset, it would close editing in another quarter second. Anyway, problem solved, thx Emile.

1 Like