Want TAB key to *not* change focus

In my application, I have a custom control (based upon a Container Control), and with this control only, I want to capture TAB key presses. So if this control has focus, and a TAB key is pressed, it gets a KeyDown event, not focus changing to the next control.

Is this possible and how?

TIA

Well, the KeyDown event of the containers is useless. Other tools even like VB6 have a KeyPreview event where you can capture the key presses in the parent container BEFORE this are sent to the controls. But in xojo, you have to capture the key presses in each control.

Add the KeyDown** event and return true if the key was Tab

If Asc(key) = 9 Then Return True

I lied. I had another look at it, its not based on a Container Control. There are a few levels of subclassing, at the base of it is a Canvas. I’ve got a KeyDown event handler in there already, which works for all other characters. I put a breakpoint in the KeyDown Event Handler, but typing a TAB, it doesn’t break…the focus changes.

Have-you tried to read the second panel in the Properties pane ?

Are you referring to AllowTabs?
There is no properties pane BTW.
I tried setting it to True in the Constructor for my subclass of Canvas but it doesn’t work.
Maybe I need to use a more recent version of Xojo.

If no properties pane, what is that ?

That’s called the Inspector. See the button on the toolbar that shows it (not the cog or ID, above that).

@Tom_Dowad If you turn off “Allow Tab Stop” setting then the key will be provided to the keydown event just like any other. With it turned on it is captured by Xojo and used to move the focus to the next control in the tab order.

I think its a case where the AllowTabs property does not work with the Canvas control, maybe just with the version of Xojo I am using. AllowTabs works with a TextArea control. AllowTabStop is a different thing, that will affect whether the focus lands on the control, not what happens when the focus is already on the control.
There are no inspector properties. I created a new class, then in the Superclass field, entered “Canvas”. When this class is selected, no properties are shown.

I did some experimenting and I solved it. I don’t know if this is the ultimate answer but it works. I had tried setting AllowTabs=True & AllowFocus = True in the Constructor of the base class. That did not work. But it worked when I did the same in the Open event.
So I imagine its a matter of the sequence of initialization.
Thanks for replies.

Just for clarity, the properties that appear in the Inspector of a control instance on a window or container are initialized after the constructor returns, so any changes that you try to do in the Constructor will be overwritten by the values defined in the inspector. That’s why you ran into this problem.