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

ElementComponent 'mousemove' event fires outside element when LMB is pressed #4755

Open
mgawinKatana opened this issue Oct 17, 2022 · 0 comments · May be fixed by #4819
Open

ElementComponent 'mousemove' event fires outside element when LMB is pressed #4755

mgawinKatana opened this issue Oct 17, 2022 · 0 comments · May be fixed by #4819
Labels
area: ui UI related issue bug

Comments

@mgawinKatana
Copy link

Description

Event 'mousemove' is invoked on ElementComponent, with useInput set to true, when mouse is outside the element but previously LMB was pressed inside this element. Works correctly on engine version 1.55.0.

const TestMouse = pc.createScript('testMouse');
TestMouse.attributes.add('status', { type: 'entity' });
TestMouse.attributes.add('target', { type: 'entity' });

TestMouse.prototype.initialize = function() {
    this.isOver = false;
    this.targetElement = this.target?.element;
    if (!this.targetElement) return;

    this.targetElement.on('mouseenter', this.onEnter, this);
    this.targetElement.on('mouseleave', this.onLeave, this);
    this.targetElement.on('mousemove', this.onMove, this);
};
TestMouse.prototype.update = function() {
    this.status.element.text = 'Over UI: ' + this.isOver;
};
TestMouse.prototype.onEnter = function() {
    this.isOver = true;
};
TestMouse.prototype.onLeave = function() {
    this.isOver = false;
};
TestMouse.prototype.onMove = function() {
    this.isOver = true;
};

Steps to Reproduce

  1. Go to: https://launch.playcanvas.com/1563175?debug=true
  2. Press and hold LMB inside white rectangle and move mouse outside the rectangle
  3. Text on top will still show that mouse is inside ui
  4. Now go to: https://launch.playcanvas.com/1563175?debug=true&version=1.55.0 <- notice older version
  5. Repeat step 2
  6. Now event will work correctly, text on top will change to false
@yaustar yaustar added bug area: ui UI related issue labels Oct 17, 2022
@kungfooman kungfooman linked a pull request Nov 6, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ui UI related issue bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants