The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Mouse clicks
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mike Buess

USA
3037 Posts

Posted - 05/28/2005 :  10:52:20 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: XP

I have a DialogBuilder toolbar and am looking for ways to trigger alternative button actions without using modifier keys (e.g., a button does A on click and B on Ctrl+click). The right mouse button will not activate a toolbar button but one can tell whether or not the right button is depressed during a left-click with GetKeyState(MK_RBUTTON). Unfortunately, it's rather awkward to use both mouse buttons simultaneously. Furthermore, when the right MB is pressed the first left-click is ignored so two left-clicks are needed to activate the toolbar button. (As long as you hold the right MB down all subsequent left-clicks are registered.) It occurred to me that I could dispense with the right MB if double-clicks could somehow be distinguished from single-clicks. Is that possible with OC? If not, is it possible to delay a script or OC function for a short period of time (say 0.5 seconds) and register that a second click has occurred in that interval? Perhaps using the timerproc macro?

Any alternatives that do not involve the keyboard are welcomed.

I found a tentative solution using the timerProc macro...

[Toolbar.Btn.OnClick]
if( timerFlag==0/0 ) {
timerFlag=0;
def timerProc {
timer -k;
del -v timerFlag;
ty Execute A; // action on single-click
};
timer 0.3;
};
else {
timer -k;
del -v timerFlag;
ty Execute B; // action on double-click
}

The timer interval (0.3 seconds for my reactions and PC) will need to be adjustable by the user but that's probably OK. But I'd still to hear about alternative solutions.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 05/28/2005 12:01:36 PM

Mike Buess

USA
3037 Posts

Posted - 05/29/2005 :  09:48:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Windows' double-click speed (in milliseconds) can be obtained from the registry with OC so the following approach works fine for standard mice. However, mice with their own drivers (Kensington and others) might not store their settings in the same place so I'm still open to alternatives. For example, can DialogBuilder buttons be programmed to respond to right-clicks?
// Origin C function
double GetDoubleClick()
{
Registry reg(HKEY_CURRENT_USER);
string dblClick;
reg.GetValue("Control Panel\\Mouse", "DoubleClickSpeed", dblClick);
return atof(dblClick)/1000;
}

// LabTalk button script
[Toolbar.Btn.OnClick]
if(DoubleClickSpeed==0/0) DoubleClickSpeed = GetDoubleClick();
if( timerFlag==0/0 ) {
timerFlag=0;
def timerProc {
timer -k;
del -v timerFlag;
ty Execute A; // action on single-click
};
timer DoubleClickSpeed;
} else {
timer -k;
del -v timerFlag;
ty Execute B; // action on double-click
};


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 05/29/2005 09:49:45 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000