This commit is contained in:
Uwe Rathmann 2023-05-15 12:22:55 +02:00
parent b25852ff6f
commit b7fe24602c
2 changed files with 9 additions and 4 deletions

View File

@ -432,8 +432,10 @@ QRectF QskMenu::focusIndicatorRect() const
if( currentIndex() >= 0 ) if( currentIndex() >= 0 )
{ {
auto actionIndex = qskActionIndex( m_data->actions, currentIndex() );
return effectiveSkinlet()->sampleRect( this, return effectiveSkinlet()->sampleRect( this,
contentsRect(), Segment, currentIndex() ); contentsRect(), Segment, actionIndex );
} }
return Inherited::focusIndicatorRect(); return Inherited::focusIndicatorRect();
@ -441,8 +443,10 @@ QRectF QskMenu::focusIndicatorRect() const
QRectF QskMenu::cellRect( int index ) const QRectF QskMenu::cellRect( int index ) const
{ {
const auto actionIndex = qskActionIndex( m_data->actions, index );
return effectiveSkinlet()->sampleRect( return effectiveSkinlet()->sampleRect(
this, contentsRect(), QskMenu::Segment, index ); this, contentsRect(), QskMenu::Segment, actionIndex );
} }
int QskMenu::indexAtPosition( const QPointF& pos ) const int QskMenu::indexAtPosition( const QPointF& pos ) const

View File

@ -211,7 +211,7 @@ QRectF QskMenuSkinlet::cursorRect(
const auto count = sampleCount( skinnable, QskMenu::Segment ); const auto count = sampleCount( skinnable, QskMenu::Segment );
auto rect = sampleRect( skinnable, contentsRect, auto rect = sampleRect( skinnable, contentsRect,
QskMenu::Segment, qBound( 0, index, count ) ); QskMenu::Segment, qBound( 0, index, count - 1 ) );
if ( index < 0 ) if ( index < 0 )
rect.setBottom( rect.top() ); rect.setBottom( rect.top() );
@ -375,7 +375,8 @@ QskAspect::States QskMenuSkinlet::sampleStates(
if ( subControl == Q::Segment || subControl == Q::Icon || subControl == Q::Text ) if ( subControl == Q::Segment || subControl == Q::Icon || subControl == Q::Text )
{ {
const auto menu = static_cast< const QskMenu* >( skinnable ); const auto menu = static_cast< const QskMenu* >( skinnable );
if ( menu->currentIndex() == index )
if ( menu->currentIndex() == menu->actions()[ index ] )
states |= QskMenu::Selected; states |= QskMenu::Selected;
} }