I have a Tabpanel with 2 Listboxes on it.
On one of the panels I type in some numbers.
When I finish the input of the number by ENTER I check if the numbers are correct (not too big and not to small).
This works.
After closing the input ( no more frame around the cell) I can switch over to the other Panel.
BUT if I do not end the input (not press ENTER, still the frame around the cell) and then switch over to the other Panel my program crashes.
So my question is:
How can I detect if the input is finished and if it is not finished just finish it programmatically (pressing ENTER)?
I have tried different event handlers but none worked.
The only event you will get is the TabPanel’s Change event. There, you must detect that you are editing a cell. You should probably set a flag in CellGotFocus and clear it when you press Enter. More to the point, though, is to figure out why the program is crashing. That indicates some code is making bad assumptions, which could cause other kinds of problems down the road.
I set a flag in CellGotFocus and I can detect it in the Change event.
How can I then press ENTER by code to close the edit mode of the cell?
If I press ENTER manually all is fine.
The problem is that after typing in some numbers you can forget to close the edit mode at the last number. And this causes the crash when changing the panel. If I do not forget to press ENTER all is fine.
[quote=245373:@Ulrich Trutter]I set a flag in CellGotFocus and I can detect it in the Change event.
How can I then press ENTER by code to close the edit mode of the cell?
If I press ENTER manually all is fine.
The problem is that after typing in some numbers you can forget to close the edit mode at the last number. And this causes the crash when changing the panel. If I do not forget to press ENTER all is fine.[/quote]
What do you mean with crashes? Do you get a hard crash or do you simply get an exception? If yes, which one? If you really get a crash post the crash log.
I don’t think you can prevent switching tabsheets with the default ones. You could do this with custom tabsheets like mine from http://www.mothsoftware.com/content/xojo/ .
Define “does not work”. What do you expect and what does it actually do? What events are firing?
And there is no way your code should be crashing. Please explain that a little more.
A really simple app with a tab panel & two listboxes that are editable doesn’t “crash” when you switch
No custom code in the lists at all
What ever you’re experiencing is likely related to what ever code you’ve added
So I’d suggest posting code or a sample app that shows the problem you’re experiencing so we can be more helpful
In the CellGotFocus-event of ListBox2 I set a global variable to TRUE, so that I can detect the EditMode.
In the MouseDown-event of the TabPanel I read this global variable. And if it is TRUE I use ListBox1.SetFocus() (the Listbox where the user forgot to press ENTER). At the same time I reset the global variable to FALSE.
Thanks for all your contributions which in the end set me on the correct path.