_dispatch_event captures M at closure-definition time; with M declared
further down the file, the capture resolved to global M (nil), causing
'attempt to index a nil value (global M)' every frame the panel was open
and a mouse event was dispatched. Hoisting the table declaration above
the dispatch helpers fixes the resolution at compile time.