Skip to content

FlxButton mouseups don't occur during VCR recording/playback #1729

Closed
@IBwWG

Description

  • Flixel version: dev
  • OpenFL version: 3.6.0
  • Lime version: 2.9.0
  • Affected targets: flash, probably all?

Code snippet reproducing the issue:

// in update():
if (FlxG.mouse.justPressed) {
    trace( 'mouse down at ', FlxG.mouse.getWorldPosition() );
}
if (FlxG.mouse.justReleased) {
    trace( 'mouse up at ', FlxG.mouse.getWorldPosition() );
}
// and also the typical recording/playback code, e.g. from the Replay demo

Extra steps to reproduce:
When you record, make sure to click without moving the cursor position at all.


Observed behavior: Your .fgr will contain lines like this:

84km478,95,2,0
85km478,95,1,0
86km478,95,1,0
87km
88km
89km
90km

Thus, on playback, the above code snippet does not trace any mouseups, even though during recording it does.

Expected behavior: The .fgr should contain one more update to trigger a mouseup, I think:

84km478,95,2,0
85km478,95,1,0
86km478,95,1,0
87km478,95,-1,0
88km
89km
90km

Alternatively, the playback function should somehow set FlxG.mouse.justReleased at 87km when it sees that the mouse is no longer pressed. I think it's "more correct" to record the mouseup, but maybe it's easier to fix playback than it is to fix recording.

Upon further investigation, it seems that this behaviour is quite intentional. FlxMouse.hx has:

        if ((_lastX == _globalScreenX) && (_lastY == _globalScreenY) 
            && (_leftButton.released) && (_lastWheel == wheel))
        {
            return null;
        }

So far I've traced that intention back at least three years (well, almost--as far back as the repo seems to go, Aug 2013), but I don't understand the rationale behind it.

In fact, it breaks FlxButton behaviour, which depends on mouseups to function properly. I just tried this case (clicking a FlxButton without moving the cursor between mousedown and mouseup) and it does indeed seem broken: during recording the button records a press, but during playback it doesn't.

So, assuming there is a good reason for having included that snippet in FlxMouse in the first place, and assuming it's still valid, there's a bit of a conflict with how FlxButtons work (not to mention my own update code, which does similar things to FlxButtons.) Depending on what that reason is, maybe we could add a flag somewhere to allow disabling this behaviour?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions