GetMouse does not record activity from MacBook's Pro trackpad

Dear PTB community,

I am using the GetMouse command inside a loop in order to get the button status and update the position of a rectangle at each iteration based on the button status of the mouse.

The idea is simple: left-click should move the rectangle to the left and right-click to the right.

When I left-click the rectangle goes to the left but this is not the case when I right-click. It again goes to the left. I think this is a problem related to my macbook’s trackpad but I have also tried to connect an apple mouse and the problem persists.

Any help would be appreciated and thanks for the amazing toolbox

P.S: My code looks like this:

    [~,~,buttons(i,:)] = GetMouse;
    if buttons(i,1) ~= 0 && buttons(i-1,1) == 0
        cursorPosition(i) = cursorPosition(i-1)-cursorStepsize
    elseif buttons(i,3) ~= 0 && buttons(i-1,3) == 0
        cursorPosition(i) = cursorPosition(i-1)+cursorStepsize
    else
        cursorPosition(i) = cursorPosition(i-1);
    end

UPDATE:

It seems that the right-click of the trackpad is registered in the second column and not third! Seems to having solved the issue.