Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Aug 18, 2017 9:39 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Double Click Revisited
PostPosted: Sun Nov 27, 2011 12:56 pm 
Offline

Joined: Tue Jan 15, 2008 1:21 am
Posts: 43
When I was trying to implement the double-click on Canvas example posted here, and had quite some trouble at the beginning. Now I have re-written the whole thing a little, to make it cross platform (Windows, OS-X). Now it should be better understandable, and it can easy adjusted for other controls as well.

A) Create a new Class and name it dcCanvas
B) Set the Super of this class to Canvas
C) Add Event Definition DoubleClick
D) Add private property mouseUpT as Integer
E) Add private property mouseUpX as Integer
F) Add private property mouseUpY as Integer
G) Define the MouseDown event:
return true

H) Define the MouseUp event:
if not IsContextualClick then
if x = me.mouseUpX and y = me.mouseUpY Then
if me.mouseUpT > ticks-me.doubleClickTime() then
RaiseEvent DoubleClick
end if
end if
me.mouseUpT = ticks
me.mouseUpX = X
me.mouseUpY = Y
end if

I) Create a private method doubleClickTime as integer:
#if targetMacOS then
#if targetMachO then
Declare Function GetDblTime Lib "Carbon" () as Integer
#elseif targetCarbon then
Declare Function GetDblTime Lib "CarbonLib" () as Integer
#elseif targetMacOSClassic then
Declare Function GetDblTime Lib "InterfaceLib" () as Integer Inline68K("2EB802F0")
#endif
return GetDblTime()
#endif

#if targetWin32 then
Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
return GetDoubleClickTime() * 6 / 100
#endif

return 30


Alternatively the doubleClickTime could be defined globally, making it available for all the "moded" classes. Also in my research if found that windows "GetDoubleClickTime" returns ms and not ticks as on OS-X. So far the examples I found, did not address that. In addition I reduced how many times the OS is called, requesting the double click time. This is not a perfect solution, but it works so far. I already used the above to modify other controls, but I yet have to test on Windows.

Edit(11/29/2011): Made some changes to the above. Now measuring the time between MouseUp and MouseDown. This improves the reaction, when the application window does not have focus.
Edit(12/1/2011): Finally got to test on Windows: The conversion from ms to ticks was wrong. Corrected the above.
Edit(12/2/2011): Changed back to measuring two mouse-downs


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Fri Jun 15, 2012 2:40 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
Why is this not just built into Real Basic?

In Visual Basic, for example, labels have a DblClick event built in.

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Fri Jun 15, 2012 4:47 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
torrid wrote:
Why is this not just built into Real Basic?

In Visual Basic, for example, labels have a DblClick event built in.

It is built in. I'm not sure what problem this code is supposed to address.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Sat Jun 16, 2012 12:00 am 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
Can u clarify?

I am looking at a Label right now and there is not any double click event.

i.e. Where is it?


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Sat Jun 16, 2012 12:52 am 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Oops, I read "Canvas" instead of "Label". :shock:

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Mon Jun 18, 2012 7:03 pm 
Offline

Joined: Tue Jan 15, 2008 1:21 am
Posts: 43
charonn0 wrote:
It is built in. I'm not sure what problem this code is supposed to address.


Sorry, that was not always the case with earlier versions of RB. There was a point in time, where Canvas had no double-click event. Anyhow you can adjust the above code for elements that do not have a double-click like Label. Therefore it still has some validity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Mon Jul 23, 2012 6:29 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
Yes LABEL, not canvas, is where I am looking for a double click event... I still don't understand why it does not have it. I may indeed take this code on later but for now am moving the code to some other event... that will get me by for now.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click Revisited
PostPosted: Mon Jul 23, 2012 8:38 pm 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
You're right, and it is a bit odd that the DoubleClick event isn't from the RectControl super. I recommend checking Feedback to see if it has a feature request — if there isn't one, make one. :)

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


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

All times are UTC - 5 hours


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group