Skip to content

PieMenu: Ensure popup menu stays within viewport#2514

Draft
dl3sdo wants to merge 2 commits into
OpenOrienteering:masterfrom
dl3sdo:fix-piemenu-position
Draft

PieMenu: Ensure popup menu stays within viewport#2514
dl3sdo wants to merge 2 commits into
OpenOrienteering:masterfrom
dl3sdo:fix-piemenu-position

Conversation

@dl3sdo

@dl3sdo dl3sdo commented Jun 10, 2026

Copy link
Copy Markdown
Member

The popup pie menu would be clipped when overflowing the screen edges. To avoid clipping, use the existing dead code to shift position.
pie_menu_clipped

The popup pie menu would be clipped when overflowing the screen edges.
To avoid clipping, use the existing dead code to shift position.
@dl3sdo

dl3sdo commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

I'll either add an Q_UNUSED(pos); or modify a copy of pos.
Actually it does not make much difference:
While pos is captured when the user pressed the mouse button, QCursor::pos(); is captured after the event has been received. I assume no-one to right click while doing a rapid mouse move.

@dg0yt

dg0yt commented Jun 10, 2026

Copy link
Copy Markdown
Member

Hm, how is popup(pos) intented to work?
I assume it should show the popup next to pos; i.e. use that pos everywhere; do not use QCursor::pos() at all.

@dl3sdo

dl3sdo commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

MapWidget::_mousePressEvent() calls context_menu->popup(event->globalPos()); (with context_menu = new PieMenu(this);).
See QMouseEvent::globalPos() const
Ok, it seems that you prefer the modification of a copy of pos.

@dg0yt dg0yt marked this pull request as draft June 19, 2026 05:49
@dg0yt

dg0yt commented Jun 19, 2026

Copy link
Copy Markdown
Member

To be revised after #2513.
Fun fact: I can skip the calculation and still the popup will be positioned on the screen...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants