Page 1 of 1

TabStop on custom control

Posted: Mon Nov 11, 2019 11:41 pm
by ChrisBear
I am new to wxWidgets, but have been using C++Builder since it was first released by Borland. I want to be able to use Linux so have jumped ship.

I'm trying to create a custom control which accepts focus on tab / shift tab, and can be created dynamically (screen layout loaded from file at run time).

I have tried deriving from wxWindow and wxControl and neither seem to accept focus.

Having tried placing normal buttons on the window at design time, it appears Tab does nothing unless the buttons are placed on a wxPanel.

Unfortunately, as soon at a wxPanel is placed on the form, even if it's just a tiny square in one corner, the custom controls fail to appear at all.

If all else fails, I presume I just capture the tab key in the main window event handling and do it the hard way. Not a huge problem as I only have one form, however it would be nice to be able to do it natively.

Any suggestions would be gratefully received.

Re: TabStop on custom control

Posted: Tue Nov 12, 2019 1:45 am
by catalin
ChrisBear wrote:
Mon Nov 11, 2019 11:41 pm
Having tried placing normal buttons on the window at design time, it appears Tab does nothing unless the buttons are placed on a wxPanel.
By "window" there you probably mean wxFrame or wxDialog.
Either way, just place a wxPanel on whatever "window" you are using, then place the buttons on the wxPanel.

Re: TabStop on custom control

Posted: Tue Nov 12, 2019 3:13 pm
by ONEEYEMAN
Hi,
ChrisBear wrote:
Mon Nov 11, 2019 11:41 pm
I am new to wxWidgets, but have been using C++Builder since it was first released by Borland. I want to be able to use Linux so have jumped ship.

I'm trying to create a custom control which accepts focus on tab / shift tab, and can be created dynamically (screen layout loaded from file at run time).

I have tried deriving from wxWindow and wxControl and neither seem to accept focus.

Having tried placing normal buttons on the window at design time, it appears Tab does nothing unless the buttons are placed on a wxPanel.

Unfortunately, as soon at a wxPanel is placed on the form, even if it's just a tiny square in one corner, the custom controls fail to appear at all.
If it fails to appear, it means you gave it a wrong parent.
Change the parent window to be wxPanel, and everything will show up.

Thank you.

Re: TabStop on custom control

Posted: Tue Nov 12, 2019 11:43 pm
by ChrisBear
ONEEYEMAN wrote:
Tue Nov 12, 2019 3:13 pm
Hi,
ChrisBear wrote:
Mon Nov 11, 2019 11:41 pm
I am new to wxWidgets, but have been using C++Builder since it was first released by Borland. I want to be able to use Linux so have jumped ship.

I'm trying to create a custom control which accepts focus on tab / shift tab, and can be created dynamically (screen layout loaded from file at run time).

I have tried deriving from wxWindow and wxControl and neither seem to accept focus.

Having tried placing normal buttons on the window at design time, it appears Tab does nothing unless the buttons are placed on a wxPanel.

Unfortunately, as soon at a wxPanel is placed on the form, even if it's just a tiny square in one corner, the custom controls fail to appear at all.
If it fails to appear, it means you gave it a wrong parent.
Change the parent window to be wxPanel, and everything will show up.

Thank you.
I tried placing the panel in the whole frame, and then using that as parent. I also tried placing a tiny panel in the corner and leaving the parent set as the frame. In both cases, the controls failed to appear. With the panel deleted (and parent set to frame) the controls appeared.

Would placing a panel in a frame take over paint events from the frame ? It has occurred to me that another custom control which is repainted from a timer (live video window) is still there.

Re: TabStop on custom control

Posted: Wed Nov 13, 2019 12:01 am
by doublemax
I tried placing the panel in the whole frame, and then using that as parent. I also tried placing a tiny panel in the corner and leaving the parent set as the frame. In both cases, the controls failed to appear.
I think we need to see some code now. It's hard to tell what you're doing wrong just by hearing the description of what (you think) you did.
Would placing a panel in a frame take over paint events from the frame ?
No. But if you draw something in the paint event of the frame, and the frame is covered with a wxPanel, whatever you drew on the frame will not be visible.