本文整理汇总了C++中wxNavigationKeyEvent::GetCurrentFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ wxNavigationKeyEvent::GetCurrentFocus方法的具体用法?C++ wxNavigationKeyEvent::GetCurrentFocus怎么用?C++ wxNavigationKeyEvent::GetCurrentFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxNavigationKeyEvent
的用法示例。
在下文中一共展示了wxNavigationKeyEvent::GetCurrentFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleOnNavigationKey
void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
{
// for a TLW we shouldn't involve the parent window, it has nothing to do
// with keyboard navigation inside this TLW
wxWindow *parent = m_winParent->IsTopLevel() ? NULL
: m_winParent->GetParent();
// the event is propagated downwards if the event emitter was our parent
bool goingDown = event.GetEventObject() == parent;
const wxWindowList& children = m_winParent->GetChildren();
// if we have exactly one notebook-like child window (actually it could be
// any window that returns true from its HasMultiplePages()), then
// [Shift-]Ctrl-Tab and Ctrl-PageUp/Down keys should iterate over its pages
// even if the focus is outside of the control because this is how the
// standard MSW properties dialogs behave and we do it under other platforms
// as well because it seems like a good idea -- but we can always put this
// block inside "#ifdef __WXMSW__" if it's not suitable there
if ( event.IsWindowChange() && !goingDown )
{
// check if we have a unique notebook-like child
wxWindow *bookctrl = NULL;
for ( wxWindowList::const_iterator i = children.begin(),
end = children.end();
i != end;
++i )
{
wxWindow * const window = *i;
if ( window->HasMultiplePages() )
{
if ( bookctrl )
{
// this is the second book-like control already so don't do
// anything as we don't know which one should have its page
// changed
bookctrl = NULL;
break;
}
bookctrl = window;
}
}
if ( bookctrl )
{
// make sure that we don't bubble up the event again from the book
// control resulting in infinite recursion
wxNavigationKeyEvent eventCopy(event);
eventCopy.SetEventObject(m_winParent);
if ( bookctrl->GetEventHandler()->ProcessEvent(eventCopy) )
return;
}
}
// there is not much to do if we don't have children and we're not
// interested in "notebook page change" events here
if ( !children.GetCount() || event.IsWindowChange() )
{
// let the parent process it unless it already comes from our parent
// of we don't have any
if ( goingDown ||
!parent || !parent->GetEventHandler()->ProcessEvent(event) )
{
event.Skip();
}
return;
}
// where are we going?
const bool forward = event.GetDirection();
// the node of the children list from which we should start looking for the
// next acceptable child
wxWindowList::compatibility_iterator node, start_node;
// we should start from the first/last control and not from the one which
// had focus the last time if we're propagating the event downwards because
// for our parent we look like a single control
if ( goingDown )
{
// just to be sure it's not used (normally this is not necessary, but
// doesn't hurt neither)
m_winLastFocused = NULL;
// start from first or last depending on where we're going
node = forward ? children.GetFirst() : children.GetLast();
}
else // going up
{
// try to find the child which has the focus currently
// the event emitter might have done this for us
wxWindow *winFocus = event.GetCurrentFocus();
// but if not, we might know where the focus was ourselves
if (!winFocus)
winFocus = m_winLastFocused;
//.........这里部分代码省略.........