TabStop on custom control

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
ChrisBear
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 11, 2019 11:18 pm

TabStop on custom control

Post 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.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: TabStop on custom control

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: TabStop on custom control

Post 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.
ChrisBear
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 11, 2019 11:18 pm

Re: TabStop on custom control

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: TabStop on custom control

Post 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.
Use the source, Luke!
Post Reply