Added callbacks for onOpenBegin and onCloseBegin. Currently applies to both primary and secondary menu in the same way.