Skip to content

Fix Utiliti crash on macOS from right-click input#952

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-utiliti-crash-on-mac-osx
Draft

Fix Utiliti crash on macOS from right-click input#952
Copilot wants to merge 2 commits intomainfrom
copilot/fix-utiliti-crash-on-mac-osx

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 23, 2026

Context

On macOS, right-clicking (or two-finger trackpad click) in Utiliti caused an immediate crash. Root cause: Java fires isPopupTrigger() on mousePressed on macOS, but on mouseReleased on Windows/Linux. The existing popup handlers only checked SwingUtilities.isRightMouseButton() in mouseReleased, which is not the correct cross-platform pattern.

From the Java docs:

Popup menus are triggered differently on different systems. Therefore, isPopupTrigger should be checked in both mousePressed and mouseReleased for proper cross-platform functionality.

Summary

UI.java / MapList.java — popup trigger handling
Added mousePressed handlers and replaced SwingUtilities.isRightMouseButton(e) with e.isPopupTrigger() in both mousePressed and mouseReleased:

canvas.addMouseListener(new MouseAdapter() {
  @Override public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) { /* show popup */ }  // macOS triggers here
  }
  @Override public void mouseReleased(MouseEvent e) {
    if (e.isPopupTrigger()) { /* show popup */ }  // Windows/Linux trigger here
  }
});

Removed the now-unused SwingUtilities import from MapList.java.

Mouse.java — button state tracking
setPressed(false) was called on any single button release. Fixed to only clear pressed when all tracked buttons (left + right) are released, preventing state corruption when right-clicking while holding the left button.

MapComponent.java — dead code removal
Removed an unreachable right-click check inside the CREATE branch of handleMouseReleased. The method's early return on !isLeftMouseButton already exits before that branch is entered.

Additional thoughts

No Mac hardware is available for direct testing. The fix follows the standard Java cross-platform popup pattern and should resolve the macOS-specific crash without affecting Windows/Linux behavior.

Quality assurance

  • Wrote unit tests for new behaviour
  • Documented new code thoroughly
  • Fixed issues that would be regarded as code smells by sonarcloud
  • Ensured integrity of the build pipeline
Original prompt

This section details on the original issue you should resolve

<issue_title>Utiliti crashes on Mac OS X from any right click input</issue_title>
<issue_description>Describe the bug
The Mac OSX Utiliti app crashes immediately after any "right click" (or two finger click on a trackpad) input. Is this expected behavior?

Stack Trace
There is no crash file in any of the directories, so I do not not what is going wrong. Could you advise on how to get a view of the Java console when launching the app?

To Reproduce
Steps to reproduce the behavior:

  1. Download latest Mac OSX artifact for Utiliti on itch.io and unpack
  2. Launch the app
  3. Right click (two finger click on trackpad)

Expected behavior
I assumed that right clicking would open context menus for interface elements. If this is not the intended behavior, then at the very least the app should not crash seeing as right click / trackpad two finger clicking is a pretty standard interface gesture. At the very least it should ignore it, if there is indeed no intended right-click behavior.

Screenshots
If applicable, add screenshots to help explain your problem.

Your System:
LITIENGINE version: 0.11.1
Processor: Apple M1 Max
OS: macOS Tahoe 26.1
Java: OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode, sharing)
Resolution: 1728 x 1117 (system default)
</issue_description>

Comments on the Issue (you are @copilot in this section)

@nightm4re94 Thanks for the report! This is definitely not expected behaviour, we have several right click context menus across the editor. Unfortunately we don't have any Mac hardware to test on, so we're kind of flying blind with Mac releases. What you could do to identify the issue: locate the utiliti jar file in the mac archive and start it from the shell with `java -jar path/to/utiliti.jar`, that should give you the log output.

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

…d and mouseReleased

Co-authored-by: nightm4re94 <26114385+nightm4re94@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gurkenlabs/litiengine/sessions/4db57302-960d-4666-a1c1-27f498cb79d2
Copilot AI changed the title [WIP] Fix Utiliti crash on Mac OS X from right click input Fix Utiliti crash on macOS from right-click input Mar 23, 2026
Copilot AI requested a review from nightm4re94 March 23, 2026 23:58
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.

Utiliti crashes on Mac OS X from any right click input

2 participants