It is currently Tue Oct 27, 2020 1:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Mon May 30, 2011 6:51 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1770
Location: Germany
Polo wrote:
If it's not possible, then a function to get the doubleclick time (like GetDoubleClickTime_() but crossplatform) :)

A cross-platform procedure to obtain the double click time: :P
Code:
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")


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Mon May 30, 2011 7:29 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Mar 18, 2007 2:26 pm
Posts: 342
Location: Munich, Germany
Shardik wrote:
Code:
CompilerCase #PB_OS_MacOS
      DoubleClickTime = Int(GetDblTime() * 16.666667)


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?

If not the (Window)Timer for the actual double click event needs OS dependent code as well.


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Mon May 30, 2011 7:54 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2422
Location: UK
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 :)


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Mon May 30, 2011 8:03 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1770
Location: Germany
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?


Apple'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).

1 Tick = 1/60 sec = 16.666667 ms

Don't you trust me, TomS ? :lol:

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! :twisted:


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Mon May 30, 2011 8:04 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2422
Location: UK
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! :twisted:

:mrgreen:


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Wed Aug 17, 2011 10:02 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5813
Location: Germany
I added the double click events and a native DoubleClickTime() function as well :)

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Thu Aug 18, 2011 12:23 am 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2422
Location: UK
freak wrote:
I added the double click events and a native DoubleClickTime() function as well :)

Thanks! :)


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget - Double click event
PostPosted: Fri Aug 19, 2011 1:16 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1853
Awesome, thanks for the addition freak!

_________________
On GitHub: PB Includes - IDE Tools - Color Themes - IDE Branches - TabBarGadget Mods


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Baidu [Spider] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye