in reply to Trying to create a toolbar

You are talking of a web inteface ...

You must trap some client-side events. I think there is no solution in perl (server-side language).

use javascript to solve your problem.