Make a tipical push and release button


Recommended Posts

Perhaps the question has already been done, but I would not have found.

I would create a "button" to its pressure to give a value of 1 to my variable and its release returns to 0, so to speak not a function of type "toggle between".

I hope I have explained the problem correctly, sorry for my bad english.

thanks

Bufere

Link to comment
Share on other sites

You'll see if you select the Quick Sequence action for a button (or variable value, descriptive text or symbol component) an option that says "On Mouse Down". To make a button as you describe, create two actions, one with On Mouse Down checked. So:

Action #1:

On Mouse Down checked

myVar = 1

Action #2

On Mouse Down not checked

myVar = 0

Link to comment
Share on other sites

  • 4 weeks later...

Sure, use the OnKeyDown and OnKeyUp system events. Activate the horn on key down, and deactivate it on key up. These are actual sequences you will create. You might look at the setFocus sample included in the latest 5.87 release as it uses the OnKeyDown event.

Link to comment
Share on other sites

Hm. I don't see what I'm doing wrong. I created both an OnKeyDown and an OnKeyUp sequence, and as an example of my code, here's what I put in OnKeyDown:

if (key == 107)
   device.ProXR.Write(chra({0xFE,0x07}))
   return(1)
endif
return(0)

Nothing happens when I'm on a page, as instructed. Is it that I didn't declare OnKeyDown(109,0,0) somewhere?

Mike

Link to comment
Share on other sites

Guru,

Works fine this morning. Thank you for your guidance. The OnKeyDown code looks like this, and the OnKeyUp is identical save for the device command:

? key
if (key == 107)
   device.ProXR.Write(chra({0xFE,0x0F}))
   return(1)
endif
return(0)

Avoid making the OnKeyDown and OnKeyUp sequences auto-starting, as they will throw an error on CTL startup.

This really works well for my horn application. Thanks again. The more I learn, the more I love DF!

Mike

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.