Skip to content

Commit

Permalink
TMenuView: distinguish between menu bars and menu popups properly whe…
Browse files Browse the repository at this point in the history
…n handling events
  • Loading branch information
magiblot committed Oct 25, 2024
1 parent a99d342 commit c1715cf
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/tvision/tmnuview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ ushort TMenuView::execute()
{
if ( current != lastTargetItem )
action = doSelect;
else if ( !parentMenu )
// If a main menu entry was closed, exit and stop listening
else if ( size.y == 1 )
// If a menu bar entry was closed, exit and stop listening
// for events.
action = doReturn;
else
Expand All @@ -248,7 +248,7 @@ ushort TMenuView::execute()
}
else if ( mouseActive && !mouseInView(e.mouse.where) )
action = doReturn;
else if ( parentMenu )
else if ( size.y != 1 )
// When MouseUp happens inside the Box but not on a highlightable entry
// (e.g. on a margin, or a separator), either the default or the first
// entry will be automatically highlighted. This was added in Turbo Vision 2.0.
Expand All @@ -270,26 +270,26 @@ ushort TMenuView::execute()
// A menu bar entry closed by clicking on its name stays highlighted
// until MouseUp. If mouse drag is then performed and a different
// entry is selected, it will open up automatically.
else if ( mouseActive && !parentMenu && current != lastTargetItem )
else if ( size.y == 1 && mouseActive && current != lastTargetItem )
autoSelect = True;
}
break;
case evKeyDown:
switch( ctrlToArrow(e.keyDown.keyCode) )
switch( e.keyDown.keyCode )
{
case kbUp:
case kbDown:
if( size.y != 1 )
trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbDown));
trackKey(Boolean(e.keyDown.keyCode == kbDown));
else if( e.keyDown.keyCode == kbDown )
autoSelect = True;
break;
case kbLeft:
case kbRight:
if( parentMenu == 0 )
trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbRight));
else
action = doReturn;
if( size.y == 1 )
trackKey(Boolean(e.keyDown.keyCode == kbRight));
else if( parentMenu != 0 )
action = doReturn;
break;
case kbHome:
case kbEnd:
Expand Down

0 comments on commit c1715cf

Please sign in to comment.