qskTabChainIncrement added

This commit is contained in:
Uwe Rathmann 2018-02-06 14:57:34 +01:00
parent e91a0932e8
commit d32646c67c
3 changed files with 42 additions and 20 deletions

View File

@ -1,5 +1,6 @@
#include "QskEvent.h"
#include "QskGesture.h"
#include <QKeyEvent>
static void qskRegisterEventTypes()
{
@ -17,6 +18,27 @@ static void qskRegisterEventTypes()
Q_CONSTRUCTOR_FUNCTION( qskRegisterEventTypes )
int qskTabChainIncrement( const QEvent* event )
{
if ( event && event->type() == QEvent::KeyPress )
{
const auto keyEvent = static_cast< const QKeyEvent* >( event );
if ( !( keyEvent->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) )
{
switch( keyEvent->key() )
{
case Qt::Key_Tab:
return 1;
case Qt::Key_Backtab:
return -1;
}
}
}
return 0;
}
QskEvent::QskEvent( QskEvent::Type type ):
QEvent( static_cast< QEvent::Type >( type ) )
{

View File

@ -99,4 +99,6 @@ private:
const State m_state;
};
QSK_EXPORT int qskTabChainIncrement( const QEvent* );
#endif

View File

@ -8,6 +8,7 @@
#include "QskAspect.h"
#include "QskSetup.h"
#include "QskSkin.h"
#include "QskEvent.h"
#include <QtMath>
#include <QPointer>
@ -259,9 +260,7 @@ bool QskWindow::event( QEvent* event )
void QskWindow::keyPressEvent( QKeyEvent* event )
{
if ( !( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) )
{
if ( ( event->key() == Qt::Key_Backtab ) || ( event->key() == Qt::Key_Tab ) )
if ( qskTabChainIncrement( event ) != 0 )
{
auto focusItem = activeFocusItem();
if ( focusItem == nullptr || focusItem == contentItem() )
@ -285,7 +284,6 @@ void QskWindow::keyPressEvent( QKeyEvent* event )
return;
}
}
}
Inherited::keyPressEvent( event );
}