making QskMainView a focus scope, so that the focus does not get lost,
when popups ( f.e menus ) have appeared
This commit is contained in:
parent
e64e1b6cbb
commit
1f899ebdbf
@ -4,6 +4,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskMainView.h"
|
||||
#include "QskQuick.h"
|
||||
|
||||
/*
|
||||
This code is a placeholder implementation until we know
|
||||
@ -24,6 +25,9 @@ QskMainView::QskMainView( QQuickItem* parent )
|
||||
setAutoAddChildren( false );
|
||||
setSpacing( 0 );
|
||||
setPanel( true );
|
||||
|
||||
setFlag( QQuickItem::ItemIsFocusScope, true );
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
}
|
||||
|
||||
QskMainView::~QskMainView()
|
||||
@ -90,4 +94,21 @@ void QskMainView::setFooter( QskControl* footer )
|
||||
}
|
||||
}
|
||||
|
||||
void QskMainView::focusInEvent( QFocusEvent* event )
|
||||
{
|
||||
Inherited::focusInEvent( event );
|
||||
|
||||
if ( isFocusScope() && ( scopedFocusItem() == nullptr ) )
|
||||
{
|
||||
if ( auto focusItem = nextItemInFocusChain( true ) )
|
||||
{
|
||||
if ( qskIsItemComplete( focusItem )
|
||||
&& qskIsAncestorOf( this, focusItem ) )
|
||||
{
|
||||
focusItem->setFocus( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_QskMainView.cpp"
|
||||
|
@ -27,6 +27,9 @@ class QSK_EXPORT QskMainView : public QskLinearBox
|
||||
QskControl* footer() const;
|
||||
void setFooter( QskControl* );
|
||||
|
||||
protected:
|
||||
void focusInEvent( QFocusEvent* );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user