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.
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.
P.
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.
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.