Getting Double-Click Time in RealBasic

One recent strange cross-platform bug in iSMARTtrain concerned editing sessions in the calendar view. On the Mac, double-clicking on an entry worked fine. However, on Windows, the session would open for editing even if there was quite a long pause between clicks. The Code we were using was a couple of declares:
[rbcode]
#if TargetMacOS then
Declare Function GetDblTime Lib “Carbon” () as Integer
doubleClickTime = GetDblTime()
#endif

#if targetWin32 then
Declare Function GetDoubleClickTime Lib “User32.DLL” () as Integer
doubleClickTime = GetDoubleClickTime()
#endif
[/rbcode]
We stored the time at each click using the ‘ticks()’ function, and tested the time against the value returned by the declares. After a bit of investigation, it tuned out that the Windows function returns the double-click time in milliseconds, while the Mac function returns it in ticks (60ths of a second), thus causing the problem. The simple answer to this was to convert the milliseconds reported by the Windows function to ticks, by changing the line to:
[rbcode]
doubleClickTime = GetDoubleClickTime()/16.66666
[/rbcode]
Hopefully, this post will help anyone else who comes across the same problem.

This entry was posted in REALbasic. Bookmark the permalink.