Go to Post It's good to hear I'm not nuts. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 24-01-2013, 06:45
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Toggling Buttons in Java

Quote:
Originally Posted by Ether View Post

Two different ways to turn a momentary-contact button into a toggle:

Code:
if ( buttonIsPressed() )              // test button state
    {
    if (!buttonWasPressed) toggle();  // toggle if state changed from "not pressed" to "pressed"
    buttonWasPressed=1;               // remember button state for next iteration
    }
else buttonWasPressed=0;              // remember button state for next iteration

I like this one better:

Code:
IsPressed = buttonIsPressed();          // get new button state

if (IsPressed && !WasPressed) toggle(); // toggle if state changed from "not pressed" to "pressed"

WasPressed=IsPressed;                   // remember button state for next iteration
What language is that? Buttons have no isPressed wasPressed etc
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi