Event Handling

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
nad
Posts: 15
Joined: Sat Feb 10, 2024 1:41 pm

Event Handling

Post by nad »

SpiderBasic does an excellent job compiling BASIC to client-side JavaScript/WASM, and the JS interop is powerful.
However, for developers coming from other RAD environments, one gap becomes apparent as applications grow:
Event handling remains largely manual and JavaScript-centric.
Today, UI events typically require:
Writing explicit JavaScript functions
Manually forwarding those events via sb_event()
Dispatching them again inside BASIC using EventParameter()
While this works, it adds a layer of glue code that feels unnecessary given that SpiderBasic already controls the compilation pipeline.
Feature Wish
I’d love to see SpiderBasic provide a first-class event binding abstraction,
where common client-side events can be bound directly to BASIC procedures without explicit JavaScript wrappers.
For example (illustrative syntax only):
BindEvent(#btnPrev, "click", @PrevPage())
or
Procedure PrevPage()
pageNum - 1
EndProcedure
with SpiderBasic generating the necessary JavaScript internally.
Why this would help
Reduces boilerplate JS glue code
Makes SpiderBasic feel more like a cohesive language rather than “BASIC + JS”
Lowers the barrier for database-driven applications that rely on many UI events
Encourages larger, more maintainable SpiderBasic applications
This would not remove or limit direct JavaScript access — advanced users could still use JS when needed — but it would make SpiderBasic far more productive for common application workflows.
I believe this kind of abstraction would strengthen SpiderBasic’s position as a serious client-side development tool rather than just a syntax bridge to JavaScript.
Thank you for considering this, and for the continued work on SpiderBasic.