Motion events occur when the user moves the mouse over the device window, independent of the state of any of the buttons. But we want dragging to occur only when the left button is down. Detection of this state is done in our mouse callback function. As noted in the discussion of that function, we use the boolean variable translate to indicate that an object is selected and the left button is down. Therefore, when translating is true, we pass the converted x,y location of the mouse to the selected object and the object translates itself to the new location.