openframeworks / openframeworks/openFrameworks

ofGetMousePreviousX/Y() not actually previous in event callbacks.

Open
#3,359 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core documentation section-internals
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

e.g.

void ofApp::mousePressed(int x, int y, int button)
{
    cout << x << " / " << y << endl;
    cout << ofGetPreviousMouseX() << " / " << ofGetPreviousMouseY() << endl;
    cout << "--" << endl;
}

They print out the same thing.

I'm not sure if this is a bug or not, but it was definitely unexpected.

A solution would be to make sure that our setting our previous mouse calls are called after the mouse events are dispatched.

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

Start with the ofGetPreviousMouseX() and ofGetPreviousMouseY() entry points and reproduce the issue from an ofApp::mousePressed callback using the example shown. Trace when previous mouse coordinates are updated relative to mouse event dispatch; done means the callback can observe the prior coordinates rather than the current ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.