Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix left click targeting issue #2827

Merged
merged 4 commits into from
May 4, 2021

Conversation

NickAragua
Copy link
Member

Fixes #2819

The first commit is coalescing the drag and click handling into doing the same thing, as the "drag" functionality in these displays didn't seem to be doing anything at all.

The second commit is cleaning up unused variables and enabling the user to flip arms without resetting torso twist state (technically it's a push/pop, but details).

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, just two comments first

@@ -1477,16 +1477,10 @@ public void hexMoused(BoardViewEvent b) {
if ((b.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0) {
return;
}
if (clientgui.getClient().isMyTurn()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check? I did note it wasn't part of the other ones though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored.

@NickAragua NickAragua merged commit cfc3830 into MegaMek:master May 4, 2021
@NickAragua NickAragua deleted the fix_left_click_issue branch May 4, 2021 14:19
@HoneySkull
Copy link
Collaborator

HoneySkull commented May 5, 2021

I found the root cause as to why using the BUTTON1_DOWN_MASK behaves differently than the original BUTTON1_MASK.
With the deprecated getModifiers() method, the mask is set for button 1 on both the mouse down and mouse release. With the updated getModifiersEx() the BUTTON1_DOWN_MASK is set on the mouse down but is NOT set on the mouse release.

For example FireDisplay.java and others implement this check to bail if not mouse button 1:

    // ignore buttons other than 1
    if (!clientgui.getClient().isMyTurn()
        || ((b.getModifiers() & InputEvent.BUTTON1_DOWN_MASK) == 0)) {
        return;
    }```

This used to work fine, but now, on mouseReleased() will always look like the button1 was not used and will therefore exit before doing it's left-click payload such as selecting the hex for target.

To properly fix this, BoardViewEvent that is passed into board listeners hexMouse() functions needs to carry the mouse event button clicked from the mouse event along with the mask.

I believe, if I fix this properly, the "flip/twist" functionality can be restored correctly if desired.

@HoneySkull
Copy link
Collaborator

For example, if the user presses button 1 followed by button 2, and then releases them in the same order, the following sequence of events is generated:

MOUSE_PRESSED: BUTTON1_DOWN_MASK
MOUSE_PRESSED: BUTTON1_DOWN_MASK | BUTTON2_DOWN_MASK
MOUSE_RELEASED: BUTTON2_DOWN_MASK
MOUSE_CLICKED: BUTTON2_DOWN_MASK
MOUSE_RELEASED:
MOUSE_CLICKED:

//note the mask modifiers for the releases are 0 for the button being released.

NickAragua added a commit to NickAragua/megamek that referenced this pull request May 6, 2021
…k_issue"

This reverts commit cfc3830, reversing
changes made to 2409939.
NickAragua added a commit that referenced this pull request May 6, 2021
Revert "Merge pull request #2827 from NickAragua/fix_left_click_issue"
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.

Left Clicking a Unit no longer targets the unit by default.
4 participants