本文整理汇总了C++中wxNavigationKeyEvent::SetCurrentFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ wxNavigationKeyEvent::SetCurrentFocus方法的具体用法?C++ wxNavigationKeyEvent::SetCurrentFocus怎么用?C++ wxNavigationKeyEvent::SetCurrentFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxNavigationKeyEvent
的用法示例。
在下文中一共展示了wxNavigationKeyEvent::SetCurrentFocus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnNavigationKey
void Notebook::OnNavigationKey(wxNavigationKeyEvent &e)
{
CustomTab *tab(NULL);
if ( e.IsWindowChange() ) {
if ( !m_popupWin && GetPageCount() > 0) {
m_popupWin = new NotebookNavDialog( this );
if(m_popupWin->ShowModal() == wxID_OK && m_popupWin->GetSelection()){
tab = m_popupWin->GetSelection();
size_t idx = m_tabs->TabToIndex(tab);
SetSelection(idx);
}
m_popupWin->Destroy();
m_popupWin = NULL;
if(tab) {
tab->GetWindow()->SetFocus();
}
} else if ( m_popupWin ) {
// a dialog is already opened
m_popupWin->OnNavigationKey(e);
return;
}
} else {
// pass to the parent
if ( GetParent() ) {
e.SetCurrentFocus(this);
GetParent()->GetEventHandler()->ProcessEvent(e);
}
}
}
示例2: OnNavigationKey
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
{
if ( event.IsWindowChange() )
{
// change pages
AdvanceSelection( event.GetDirection() );
}
else
{
// we get this event in 2 cases
//
// a) one of our pages might have generated it because the user TABbed
// out from it in which case we should propagate the event upwards and
// our parent will take care of setting the focus to prev/next sibling
//
// or
//
// b) the parent panel wants to give the focus to us so that we
// forward it to our selected page. We can't deal with this in
// OnSetFocus() because we don't know which direction the focus came
// from in this case and so can't choose between setting the focus to
// first or last panel child
wxWindow *parent = GetParent();
// the cast is here to fix a GCC ICE
if ( ((wxWindow*)event.GetEventObject()) == parent )
{
// no, it doesn't come from child, case (b): forward to a page
if ( m_selection != wxNOT_FOUND )
{
// so that the page knows that the event comes from it's parent
// and is being propagated downwards
event.SetEventObject( this );
wxWindow *page = m_pages[m_selection];
if ( !page->HandleWindowEvent( event ) )
{
page->SetFocus();
}
//else: page manages focus inside it itself
}
else
{
// we have no pages - still have to give focus to _something_
SetFocus();
}
}
else
{
// it comes from our child, case (a), pass to the parent
if ( parent )
{
event.SetCurrentFocus( this );
parent->HandleWindowEvent( event );
}
}
}
}
示例3: OnNavigationKey
void wxFlatNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
{
if ( event.IsWindowChange() )
{
if( HasFlag(wxFNB_SMART_TABS) )
{
if( !m_popupWin && GetPageCount() > 0)
{
m_popupWin = new wxTabNavigatorWindow( this );
m_popupWin->ShowModal();
m_popupWin->Destroy();
SetSelection((size_t)GetSelection());
m_popupWin = NULL;
}
else if( m_popupWin )
{
// a dialog is already opened
m_popupWin->OnNavigationKey( event );
return;
}
}
else
{
// change pages
AdvanceSelection(event.GetDirection());
}
}
else
{
// pass to the parent
if ( GetParent() )
{
event.SetCurrentFocus(this);
#if wxCHECK_VERSION(2, 9, 0)
GetParent()->GetEventHandler()->ProcessEvent(event);
#else
GetParent()->ProcessEvent(event);
#endif
}
}
}
示例4: HandleOnNavigationKey
//.........这里部分代码省略.........
for ( ;; )
{
// don't go into infinite loop
if ( start_node && node && node == start_node )
break;
// Have we come to the last or first item on the panel?
if ( !node )
{
if ( !start_node )
{
// exit now as otherwise we'd loop forever
break;
}
if ( !goingDown )
{
// Check if our (maybe grand) parent is another panel: if this
// is the case, they will know what to do with this navigation
// key and so give them the chance to process it instead of
// looping inside this panel (normally, the focus will go to
// the next/previous item after this panel in the parent
// panel).
wxWindow *focusedParent = m_winParent;
while ( parent )
{
// We don't want to tab into a different dialog or frame or
// even an MDI child frame, so test for this explicitly
// (and in particular don't just use IsTopLevel() which
// would return false in the latter case).
if ( focusedParent->IsTopNavigationDomain() )
break;
event.SetCurrentFocus( focusedParent );
if ( parent->GetEventHandler()->ProcessEvent( event ) )
return;
focusedParent = parent;
parent = parent->GetParent();
}
}
//else: as the focus came from our parent, we definitely don't want
// to send it back to it!
// no, we are not inside another panel so process this ourself
node = forward ? children.GetFirst() : children.GetLast();
continue;
}
wxWindow *child = node->GetData();
// don't TAB to another TLW
if ( child->IsTopLevel() )
{
node = forward ? node->GetNext() : node->GetPrevious();
continue;
}
#if defined(__WXMSW__) && wxUSE_RADIOBTN
if ( event.IsFromTab() )
{
if ( wxIsKindOf(child, wxRadioButton) )
{
示例5: OnNavigationKey
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
{
if ( event.IsWindowChange() ) {
// change pages
AdvanceSelection(event.GetDirection());
}
else {
// we get this event in 3 cases
//
// a) one of our pages might have generated it because the user TABbed
// out from it in which case we should propagate the event upwards and
// our parent will take care of setting the focus to prev/next sibling
//
// or
//
// b) the parent panel wants to give the focus to us so that we
// forward it to our selected page. We can't deal with this in
// OnSetFocus() because we don't know which direction the focus came
// from in this case and so can't choose between setting the focus to
// first or last panel child
//
// or
//
// c) we ourselves (see MSWTranslateMessage) generated the event
//
wxWindow * const parent = GetParent();
// the wxObject* casts are required to avoid MinGW GCC 2.95.3 ICE
const bool isFromParent = event.GetEventObject() == (wxObject*) parent;
const bool isFromSelf = event.GetEventObject() == (wxObject*) this;
const bool isForward = event.GetDirection();
if ( isFromSelf && !isForward )
{
// focus is currently on notebook tab and should leave
// it backwards (Shift-TAB)
event.SetCurrentFocus(this);
parent->HandleWindowEvent(event);
}
else if ( isFromParent || isFromSelf )
{
// no, it doesn't come from child, case (b) or (c): forward to a
// page but only if entering notebook page (i.e. direction is
// backwards (Shift-TAB) comething from out-of-notebook, or
// direction is forward (TAB) from ourselves),
if ( m_selection != wxNOT_FOUND &&
(!event.GetDirection() || isFromSelf) )
{
// so that the page knows that the event comes from it's parent
// and is being propagated downwards
event.SetEventObject(this);
wxWindow *page = m_pages[m_selection];
if ( !page->HandleWindowEvent(event) )
{
page->SetFocus();
}
//else: page manages focus inside it itself
}
else // otherwise set the focus to the notebook itself
{
SetFocus();
}
}
else
{
// it comes from our child, case (a), pass to the parent, but only
// if the direction is forwards. Otherwise set the focus to the
// notebook itself. The notebook is always the 'first' control of a
// page.
if ( !isForward )
{
SetFocus();
}
else if ( parent )
{
event.SetCurrentFocus(this);
parent->HandleWindowEvent(event);
}
}
}
}
示例6: OnNavigationKey
void wxNotebook::OnNavigationKey (
wxNavigationKeyEvent& rEvent
)
{
if (rEvent.IsWindowChange())
{
//
// Change pages
//
AdvanceSelection(rEvent.GetDirection());
}
else
{
//
// We get this event in 2 cases
//
// a) one of our pages might have generated it because the user TABbed
// out from it in which case we should propagate the event upwards and
// our parent will take care of setting the focus to prev/next sibling
//
// or
//
// b) the parent panel wants to give the focus to us so that we
// forward it to our selected page. We can't deal with this in
// OnSetFocus() because we don't know which direction the focus came
// from in this case and so can't choose between setting the focus to
// first or last panel child
//
wxWindow* pParent = GetParent();
if (rEvent.GetEventObject() == pParent)
{
//
// No, it doesn't come from child, case (b): forward to a page
//
if (m_nSelection != -1)
{
//
// So that the page knows that the event comes from it's parent
// and is being propagated downwards
//
rEvent.SetEventObject(this);
wxWindow* pPage = m_pages[m_nSelection];
if (!pPage->GetEventHandler()->ProcessEvent(rEvent))
{
pPage->SetFocus();
}
//else: page manages focus inside it itself
}
else
{
//
// We have no pages - still have to give focus to _something_
//
SetFocus();
}
}
else
{
//
// It comes from our child, case (a), pass to the parent
//
if (pParent)
{
rEvent.SetCurrentFocus(this);
pParent->GetEventHandler()->ProcessEvent(rEvent);
}
}
}
} // end of wxNotebook::OnNavigationKey