playcanvas / playcanvas/engine

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

Open
#4,755 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: ui
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked reproduction project and compare the current behavior with engine version 1.55.0. Trace ElementComponent input handling for useInput=true while reproducing a held left-button drag from inside to outside the rectangle. Done means mousemove no longer fires outside the element and the sample's status changes to false.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.