Key input issues with xcode 14, m1 macbook, openframeworks

I’m a total beginner in coding, for uni we started working with c++ in xcode and openframeworks.
The biggest mistake I probably made was to buy a m1 macbook pro before uni, thinking it would have no issues.
Surprise; it has many of them.

My current problem is, I have a working code for so called “amiga balls”, when i click the left mouse button one appears, with every click another randomised ball will appear. And when i click the right mouse button, the first created ball should disappear. The code works in windows with visual studio. It sadly does not work on my macbook with the m1 chip.

the code is:

void ofApp::mousePressed(int xMouse, int yMouse, int button){

if (button==0){
radius.push_back(ofRandom(20, 400));
facets.push_back(ofRandom(2, 20));
//all the other variables for the amiga balls to be created

if (button==2){
//again for all the other variables

Is there anything I have to change to make it work on my laptop? Are there any different commands?
In another task I had to use


instead of


to change the width of the line I wanted to create because ofSetLineWidth just didn’t work.

Hey @xaivu , there are some options in System Settings > Trackpad > Secondary Click that affect the behavior. ofApp::mousePressed() works as it should with the option “Click with Two Fingers” on my m1 mba.

Also there are some threads in the forum about line width, openGL versions, and etc. There are some addons that help with drawing thick lines if you need them (like ofxFatLines by roymacdonald). And the Cairo renderer in OF can be used to draw thick lines according to zach in this post.

hmm depending on the OS right click can sometimes come in as ‘1’.
An easy solution would be to change the line:

if (button==2){



Hope that helps!

sadly that didn’t work : (
the right mouse button still has no effect when i click it

i checked and my settings are already on secondary click: click with two fingers… sadly that doesn’t resolve the issue : (

Hmm weird!

Can you add this to the top of the mousePressed function:

void ofApp::mousePressed(int xMouse, int yMouse, int button){
cout << " button is: " << button << endl; 

and see what it says in the console when you do left and right click?

Note: on Mac I have to hold ctrl key while clicking with the trackpad to do a right click.

when i press the left mouse button, the console gives out “button is: 0” — when i press the right mouse button, nothing happens and the console also doesn’t give anything out

(i also work with a mouse for this task, to make sure it isn’t a problem with my trackpad settings. the mouse is fully functional i checked that already)

Hmm I think this might be a setting issue at the system level.

If you right click with your mouse in the Finder ( or other programs on macOS ) does it show a menu?


Hey darn I was hoping your trackpad settings were the issue. I did write an OF example similar to the code you posted to test on an m1 air (Xcode 14.1 and Ventura 13.0.1). The int button is 0 for a 1-finger click, and 2 for a 2-finger click. I wish I could be more help, but Theo is on it and he’s super knowledgeable. I’ll keep reading along though. Sometimes it helps to reboot macOS if you haven’t done that already.

thank you both so much for your help @theo @TimChi !!
after searching for the issue for hours it finally turned out that there was a misunderstanding with my prof in downloading the openframeworks version. but now with the correct version everything luckily works as it should! : )

1 Like

:+1: glad its working for you now!
I was very confused why it wasn’t but that explains it :smiley:

Good luck with your project!

1 Like