Menu

#2395 ScintillaEditBase::contextMenuEvent Blocks Parent Window contextMenuEvent()

Bug
closed-fixed
nobody
5
2023-09-22
2023-08-01
Gary James
No

Platform: Windows with Qt 5.15.2
Scintilla version: 5.3.5

In version 5.3.5 the ScintillaEditBase::contextMenuEvent function does not allow for the parent widget to create a pop-up menu when SCI_USEPOPUP is set to SC_POPUP_NEVER. That's because the function doesn't tell the incoming event that it's being ignored. If it is not told that it is being ignored, then it will never propagate up to the parent widget.

This:

void ScintillaEditBase::contextMenuEvent(QContextMenuEvent *event)
{
    Point pos = PointFromQPoint(event->globalPos());
    Point pt = PointFromQPoint(event->pos());
    if (!sqt->PointInSelection(pt)) {
        sqt->SetEmptySelection(sqt->PositionFromLocation(pt));
    }
    if (sqt->ShouldDisplayPopup(pt)) {
        sqt->ContextMenu(pos);
    }
}

Should be changed to:

void ScintillaEditBase::contextMenuEvent(QContextMenuEvent *event)
{
    Point pos = PointFromQPoint(event->globalPos());
    Point pt = PointFromQPoint(event->pos());
    if (!sqt->PointInSelection(pt)) {
        sqt->SetEmptySelection(sqt->PositionFromLocation(pt));
    }
    if (sqt->ShouldDisplayPopup(pt)) {
        sqt->ContextMenu(pos);
        event->accept();
    }
    else {
        event->ignore();
    }
}

Discussion

  • Neil Hodgson

    Neil Hodgson - 2023-08-01
    • labels: --> scintilla, Qt
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2023-08-01

    Committed with [753c28].

     

    Related

    Commit: [753c28]

  • Neil Hodgson

    Neil Hodgson - 2023-09-22
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB