circe wrote: ↑Mon 19 May 2025, 13:32
If SPACE BAR is pressed instead of SHIFT, when SHIFT is eventually pressed, a Message Box after output self-answers with NO (result%=6) and exits.
After a bit of experimentation it seems that this happens because pausing output (as a result of VDU 14) happens in the
UI thread rather than in the
interpreter thread. The solution is to force a 'thread synchronisation' before you clear the keyboard buffer:
Code: Select all
INSTALL @lib$+"msgbox"
INSTALL @lib$+"dlglib"
VDU 14
FOR count%=0 TO 40:PRINT" Line "STR$(count%):NEXT
IF POS REM SDL thread sync
*FX21,0
result%=FN_messagebox("Test", "Answer Yes or No", 4)
PRINT "result% is:"STR$(result%)
There's no obvious way in which this could be fixed by modifying BBCSDL itself, because you would not want to force a thread synchronisation every time you do *FX 21 (that would hurt performance) but only immediately after a VDU 14 pause had happened - but there's no easy way to detect that.
Possibly it would be acceptable to force a thread sync when a VDU 15 is issued, since that is not likely to be speed critical, but you would then need to remember to do a VDU 15 before calling FN_messagebox(), which you don't in your code (and perhaps might not want to).
The dual-threaded nature of BBCSDL does result in a number of situations when you need to force a thread synchronisation, but I hadn't realised that this was one of them. Good spot!