View Single Post
  #6   Spotlight this post!  
Unread 23-02-2013, 13:51
Itamar's Avatar
Itamar Itamar is offline
Registered User
FRC #1943 (NeatTeam) & FRC #4590 (GreenBlitz)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Israel
Posts: 83
Itamar is an unknown quantity at this point
Re: Command-Based robot button toggle question

Quote:
Originally Posted by Fifthparallel View Post
That's right. A CommandGroup inherits from Command. Whenever you press a button in the OI, it spawns a new object of XYZ CommandGroup. That is, it runs the constructor then and there on that button press (for a new Command/CommandGroup), which is exactly the functionality you want to have. On a quick test, it worked a few weeks earlier for me.
If you write in your OI constructor:

Code:
button->WhenPressed(new DoStuff());
That means one DoStuff instance is created, and that instance is passed to the "WhenPressed" function. It will be that same instance that runs every time the button is pressed. I don't see how this code will cause a new instance to be created every time the button is pressed.
Reply With Quote