Add Component to Tab Order?

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
drautb
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sat Mar 02, 2013 9:55 pm

Add Component to Tab Order?

Post by drautb » Tue Jul 16, 2013 6:55 pm

Hey All,

I'm using a custom checkbox component in my application to get around having to use a label. (http://forums.wxwidgets.org/viewtopic.php?f=21&t=37429)

The problem I have now though, is that this component isn't included in the tab order. I'm assuming that this is because it inherits from wxStaticBitmap, which overrides AcceptFocuse to always return false.

So I tried overriding it again in my component to always return true, but it still didn't solve the problem. It did change things though. Now, rather than my component being skipped when I tab through everything, my component blocks the tab from continuing. So when my component would be next in the tab order, focus stays on the current component no matter how many times you hit tab.

So, any thoughts on how to add a component to the tab order? Thanks!

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Add Component to Tab Order?

Post by doublemax » Tue Jul 16, 2013 7:24 pm

Try overriding wxWindow::AcceptsFocusFromKeyboard() too.
http://docs.wxwidgets.org/trunk/classwx ... c6aa8301b8
Use the source, Luke!

drautb
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sat Mar 02, 2013 9:55 pm

Re: Add Component to Tab Order?

Post by drautb » Tue Jul 16, 2013 7:40 pm

Same result, tabbing halts when it reaches the component.

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Add Component to Tab Order?

Post by doublemax » Tue Jul 16, 2013 8:02 pm

Hmm, no idea. Did you try wxTAB_TRAVERSAL window style flag?
Use the source, Luke!

drautb
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sat Mar 02, 2013 9:55 pm

Re: Add Component to Tab Order?

Post by drautb » Tue Jul 16, 2013 8:22 pm

Yep, I tried that too, no change.

If you don't have any other ideas, I'm thinking I may try getting it to work by using a different base component, rather than wxStaticBitmap. Do you have any suggestions if I go that route?

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Add Component to Tab Order?

Post by doublemax » Tue Jul 16, 2013 8:33 pm

Do you have any suggestions if I go that route?
I would probably use wxPanel as base class. You'd have to draw the bitmap yourself then.
Use the source, Luke!

drautb
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sat Mar 02, 2013 9:55 pm

Re: Add Component to Tab Order?

Post by drautb » Wed Jul 17, 2013 9:19 pm

Got it working, thanks!

In case anyone else finds this helpful in the future:

Header File: https://gist.github.com/drautb/5606423
Source File: https://gist.github.com/drautb/5606424

Post Reply