Listbox CellClick, EditCell = Listbox.LostFocus

I added a SegmentedControl to a Listbox and previously this wasn’t happening.

I have this code in CellClick

Me.CellType(row, column) = Listbox.TypeEditableTextField Me.EditCell(row,column)
As soon as EditCell is fired the Listbox’s LostFocus is fired.

There is no intervening code.
Also, I added TypeEditableTextField after this started happening. Any ideas about what is happening?

If the cell is editable, why not set the property when you load the cell instead of when the user clicks? The combination of changing the cell type and trying to edit it in the CellClick event may be the cause of what you are seeing.

Because in order to edit, the listbox uses a new control, which is a TextField or TextArea, which gets the focus.

See http://documentation.xojo.com/index.php/ListBox.ActiveCell

How did you do that? If you are placing a control over the listbox, then when the user clicks on the control, the listbox will lose focus. The order of events might be different than you expected, in that the click gets handled before the focus events. Is that what’s going on?

OOO. I didn’t mean TO a Listbox.

Should read: I added a SegmentedControl to a Window that has a Listbox and previously this wasn’t happening.
The lost focus happens when I click on a cell in the Listbox. The segmentedcontrol should be enabled only if a listbox has focus, but the listbox loses focus immediately.
It is also that I added the control to the window and this happened. I had pushbuttons before that were enabled if the Listbox had focus.

So. What do I do? I could make ALL the cells editable

Tim Parnell. Your comment isn’t showing. Grumble.
My confusion is my system worked fine until I changed controls.

I eliminated LostFocus from the Listbox and solved that problem. It doesn’t go out of focus. I don’t understand how but it works.

I solved my problem sort of. I added back the LostFocus event to the Listbox and that didn’t cause the event to fire.
So I decided to figure out what caused it to fire.
I added first setting a property referencing an control object to Nil and that didn’t cause it to fire.

ObjFoced = Nil

Then I added the segmented control code back and that caused it to fire.

ObjFoced = Nil RowsSegments.Items(0).Enabled = False RowsSegments.Items(1).Enabled = False

Then I eliminated the segmented control piece of code, and the LostFocus didn’t fire.

Then I added any control with enabled and it fired.

ObjFoced = Nil InfPostRad.Enabled = False

Then I changed the last piece to a method Objsetter(me) that references an object but not in LostFocus, and LostFocus doesn’t fire.

If me = GrmList Or me = FldTtleListBox Or me = RplcingBox Then RowsSegments.Items(0).Enabled = True RowsSegments.Items(1).Enabled = True ElseIf me = Nil Then RowsSegments.Items(0).Enabled = False RowsSegments.Items(1).Enabled = False End If

My problem is solved. This acts like a bug in XOJO.