Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Shifting Focus while Tabbing in a toolbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Shifting Focus while Tabbing in a toolbar

 Post Reply Post Reply
Author
Message
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Topic: Shifting Focus while Tabbing in a toolbar
    Posted: 13 June 2005 at 5:00pm
How do you shift focus along with the selection (highlight) when tabbing through controls (like CControlComboBoxEx)?

I am having trouble getting certain notifications.

Take a look at the Custom Themes Sample.  How can you make it enter focus into the "masked" combo box when the user tabs from a previous control like the "new" box?

The user should be able to start typing without having to hit <enter> first.

Thanks.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 14 June 2005 at 5:05am
Thank you for this good suggestion. We changed this behaviour.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Posted: 14 June 2005 at 9:52am
Will this change be in a future release?  If so, what did you do to move the focus?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2005 at 7:24am
It is added for 9.70 release. Key handled in CXTPCommandBar::OnKeyDown.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Posted: 01 August 2005 at 5:26pm
For those out there, I came up with an ugly hack to get the tabbing to work (the cursor enters an edit box or a dropdown, regardless of whether it is inherited from CWnd or CXTPControl) without altering the Code Jock source code.  The work-around is not pleasant, but it seems to work.  If there is a better solution, I would love to hear it.

1)  Because we cannot alter CXTPCommandBar and we cannot use a custom CommandBar, we need to make a new class that inherits from CXTPToolBar.  Call it CToolBarEx or something.

2)  When adding the toolbar that needs the tabbing behavior in CMainFrame:: OnCreate, explicitly indicate what toolbar class to use:

CXTPToolBar* pToolbar = (CXTPToolBar*)pCommandBars->Add(“Toolbar”, xtpBarTop, RUNTIME_CLASS(CToolBarEx));


3)    In the CToolBar class, override the OnKeyDown(UINT nChar).  Take note this is a custom Codejock method and not the standard OnKeyDown we all know and love.

4)    The body of the OnKeyDown should be:


if( nChar == VK_TAB )
{
  int nNum = m_pControls->GetNext(m_nSelected, +1);
  CXTPControl* pCtrl = GetControl(nNum);
  DWORD tag = pCtrl->GetTag();
  if( tag == 42 )
  {
    SetSelected(nNum, TRUE);
    SetFocusedControl(pCtrl);
    return CXTPCommandBar::OnKeyDown(VK_RETURN);
  }   
}

return CXTPToolBar::OnKeyDown(nChar);


The code essentially sets the next control up for focus and calls an extra OnKeyDown, but with VK_ENTER so that all the codejock code will perform like normal.

The ‘if(tag == 42 )’ statement is noteworthy because we want to check to see if this control requested the tabbing-enter (You might not want an Enter performed on a button).

5)  When making the control set the Tag data to flag it wants to be a part of the tab-enter in CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl).


// ...Next to your
lpCreateControl->pControl = m_pComboUrl;
// ...put
pCreateControl->pControl->SetTag( 42 );


6)  Test it
Back to Top
g_j_a_i_n View Drop Down
Groupie
Groupie
Avatar

Joined: 27 August 2005
Status: Offline
Points: 94
Post Options Post Options   Thanks (0) Thanks(0)   Quote g_j_a_i_n Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2005 at 5:23am


Fantastic !

Thank you so much for sharing. Thank you.

With your suggestion, the following statement has solved the problem:

return CXTPCommandBar::OnKeyDown(VK_RETURN);

The mistake I did was that I always returned TRUE.
I am still not sure how you got this idea.

I was having problem with removing the focus from the combo box totally. What I was not able to do.

Thanks again

Regards,
Gautam Jain

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.