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 "QskMainView.h"
|
||||||
|
#include "QskQuick.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code is a placeholder implementation until we know
|
This code is a placeholder implementation until we know
|
||||||
|
@ -24,6 +25,9 @@ QskMainView::QskMainView( QQuickItem* parent )
|
||||||
setAutoAddChildren( false );
|
setAutoAddChildren( false );
|
||||||
setSpacing( 0 );
|
setSpacing( 0 );
|
||||||
setPanel( true );
|
setPanel( true );
|
||||||
|
|
||||||
|
setFlag( QQuickItem::ItemIsFocusScope, true );
|
||||||
|
setFocusPolicy( Qt::StrongFocus );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskMainView::~QskMainView()
|
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"
|
#include "moc_QskMainView.cpp"
|
||||||
|
|
|
@ -27,6 +27,9 @@ class QSK_EXPORT QskMainView : public QskLinearBox
|
||||||
QskControl* footer() const;
|
QskControl* footer() const;
|
||||||
void setFooter( QskControl* );
|
void setFooter( QskControl* );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void focusInEvent( QFocusEvent* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
|
|
Loading…
Reference in New Issue