[Implemented] CanvasGadget - Double click event
[Implemented] CanvasGadget - Double click event
Everything is in the title
If it's not possible, then a function to get the doubleclick time (like GetDoubleClickTime_() but crossplatform)
If it's not possible, then a function to get the doubleclick time (like GetDoubleClickTime_() but crossplatform)
-
- Enthusiast
- Posts: 772
- Joined: Tue May 20, 2008 2:12 am
- Location: Cologne, Germany
- Contact:
Re: CanvasGadget - Double click event
A cross-platform procedure to obtain the double click time:Polo wrote:If it's not possible, then a function to get the doubleclick time (like GetDoubleClickTime_() but crossplatform)
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
ImportC ""
GetDblTime()
EndImport
CompilerEndIf
Procedure.I GetDoubleClickTime()
Protected DoubleClickTime.I
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
Protected GValue.GValue
Protected *Settings.GtkSettings
GValue\g_type = 6 << 2
*Settings = gtk_settings_get_default_()
If *Settings
g_object_get_property_(*Settings, "gtk-double-click-time", @GValue)
EndIf
DoubleClickTime = g_value_get_int_(@GValue)
CompilerCase #PB_OS_MacOS
DoubleClickTime = Int(GetDblTime() * 16.666667)
CompilerCase #PB_OS_Windows
DoubleClickTime = GetDoubleClickTime_()
CompilerEndSelect
ProcedureReturn DoubleClickTime
EndProcedure
MessageRequester("Info", "Double click time = " + Str(GetDoubleClickTime()) + " ms")
Re: CanvasGadget - Double click event
16.6?Shardik wrote:Code: Select all
CompilerCase #PB_OS_MacOS DoubleClickTime = Int(GetDblTime() * 16.666667)
I have no Mac, but this seems odd.
I read somewhere that some languages return the DoubleClickTime in CPU ticks rather than milliseconds.
If that's the case for the MacOS Api, 16.6 is an experimental value that may very well be different on another system. But in that case it rather be "divided by" and the number had to be higher.
Still this seems like an experimanel value.
Are you certain that is correct on each Mac?
If not the (Window)Timer for the actual double click event needs OS dependent code as well.
Re: CanvasGadget - Double click event
Yes the MacOSX multiplication is correct and works (I already had a double click cross platform system in place, I just would like to have this feature directly available in Purebasic )
I actually do * 100 / 6, but it's the same.
The reason why I'd love to have this directly from the Purebasic event is the possible switch from Carbon to Cocoa on MacOSX, which will happen one day I guess, thus why I avoid using API when i can
I actually do * 100 / 6, but it's the same.
The reason why I'd love to have this directly from the Purebasic event is the possible switch from Carbon to Cocoa on MacOSX, which will happen one day I guess, thus why I avoid using API when i can
Re: CanvasGadget - Double click event
TomS wrote:16.6?
I have no Mac, but this seems odd.
I read somewhere that some languages return the DoubleClickTime in CPU ticks rather than milliseconds.
If that's the case for the MacOS Api, 16.6 is an experimental value that may very well be different on another system. But in that case it rather be "divided by" and the number had to be higher.
Still this seems like an experimanel value.
Are you certain that is correct on each Mac?
1 Tick = 1/60 sec = 16.666667 msApple's Carbon Event Manager Programming Guide wrote:The Classic Event Manager function GetDblTime returns the current value of this interval, expressed in ticks (sixtieths of a second, the time unit used by earlier versions of Mac OS).
Don't you trust me, TomS ?
I even made the effort to verify different double click times with a stop watch on my Mac after changing them repeatedly in the System Settings!
Re: CanvasGadget - Double click event
Shardik wrote:I even made the effort to verify different double click times with a stop watch on my Mac after changing them repeatedly in the System Settings!
Re: CanvasGadget - Double click event
I added the double click events and a native DoubleClickTime() function as well
quidquid Latine dictum sit altum videtur
Re: CanvasGadget - Double click event
Thanks!freak wrote:I added the double click events and a native DoubleClickTime() function as well
Re: CanvasGadget - Double click event
Awesome, thanks for the addition freak!