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

touching mouse-pointer returns false when outside stage #2309

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

apple502j
Copy link
Contributor

Resolves

Resolves scratchfoundation/scratch-gui#5243

Proposed Changes

Adds getIsOutside function in io/mouse and uses it inside rendered-target isTouchingObject. If the param is __mouse__ and getIsOutside is true, it returns false.

Reason for Changes

See scratchfoundation/scratch-gui#5243

Test Coverage

Added one test.

@@ -280,6 +280,22 @@ test('isTouchingPoint', t => {
t.end();
});

Choose a reason for hiding this comment

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

Thanks for adding this test. Could you also please add a test where the sprite is touching the mouse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how to add that test?

Copy link
Contributor

@adroitwhiz adroitwhiz May 27, 2020

Choose a reason for hiding this comment

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

test('isTouchingMouse', t => {
    const r = new Runtime();
    const s = new Sprite(null, r);
    const renderer = new FakeRenderer();
    r.attachRenderer(renderer);
    const a = new RenderedTarget(s, r);
    a.renderer = renderer;
    r.ioDevices.mouse.postData({
        x: 0,
        y: 0
    });
    t.equals(a.isTouchingObject('__mouse__'), true);
    t.end();
});

I think this will work because FakeRenderer.drawableTouching always returns true (haven't tried it though)

@ericrosenbaum ericrosenbaum added this to the Schedule Review milestone Jun 11, 2020
@chrisgarrity chrisgarrity removed this from the Schedule Review milestone Jun 25, 2020
@apple502j
Copy link
Contributor Author

It seems like my Python knowledge is causing issues with underscored special names (see also #2427)

That should fix the test

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.

Touching Mouse Pointer returns true even if mouse is not on the stage
5 participants