mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
It read a button captured from the WH_GETMESSAGE mouse-message hook and evicted two world ticks later, so it reported a button for as long as one was held, and for a couple of frames after every click -- useless as the "am I inside a click handler" test it exists to be. 3.3.5 does none of that. The getter (FUN_0050f950) pushes a frame-manager field that only the four click dispatches ever write -- button OnClick FUN_0048fc30, OnDoubleClick FUN_0048fce0, and the two secure click paths FUN_0096fd70/FUN_0096fdd0 that wrap PreClick -> OnClick -> PostClick -- each saving the old value on the C stack, setting its own button argument, running the handler, then restoring. That C-stack save is what makes a nested click shadow the outer one and restore on unwind. 1.12 has no such field but the same bracket point: FUN_00779540 (OnClick) and FUN_00779650 (OnDoubleClick) fire their handler through the runner Frame::ClickEvents already intercepts, passing the button name as the fire's only "%s" argument. Mirror the engine's bracket there and read the name out of the fire, which also inherits the engine's own naming: Button:Click (FUN_007826C0) folds its optional string down to a numeric mask, so a bare Click() arrives as "LeftButton" and an unrecognized name as "UNKNOWN". GetMouseButtonClicked moves to Frame::ClickEvents with the dispatch it describes. IsMouseButtonDown and GLOBAL_MOUSE_* keep the message hook, which is the right source for a device query. The recursion guard now covers only the PreClick/PostClick pair, so a nested click still gets its own button scope. It now returns nil in OnMouseDown / OnMouseUp / OnDragStart, matching 3.3.5, where those paths never touch the field. Verified in-game across all four dispatches: real and programmatic clicks, OnDoubleClick, PreClick/PostClick, the nested inner/outer restore, Click() argument folding, and an OnUpdate watcher that never saw a value outside a handler.