Prevent IndexOutOfBoundsException when right clicking a button on the
functions bar