![]() |
What does SendableChooser.GetSelected() return as?
http://first.wpi.edu/FRC/roborio/rel...leChooser.html
The library says it returns as a void pointer, but what does that information return like? Does it return the name of the option that is put in with this, autoChooser.AddObject("Lowbar Auto", new Auto); "Lowbar Auto" is the name of the option, and can I use it in an if statement like, if (autoChooser.GetSelected() == "Lowbar Auto") { //Stuff for lowbar auto } |
Re: What does SendableChooser.GetSelected() return as?
I haven't used C++ for robot programming but being familiar with C and C++ APIs, it looks like it will return the object you passed in as the second parameter to AddObject().
This code: Code:
if (autoChooser.GetSelected() == "Lowbar Auto") {Also, Code:
autoChooser.AddObject("Lowbar Auto", new Auto); |
Re: What does SendableChooser.GetSelected() return as?
I knew already it didn't work, so that's why I was asking. And I found the solution anyways
autoSelected = *((std::string*)chooser->GetSelected()); if(autoSelected == autoNameCustom){ //Custom Auto goes here } else { //Default Auto goes here } |
Re: What does SendableChooser.GetSelected() return as?
Out of curiosity, did you also change your second parameter to AddObject to a std::string?
|
Re: What does SendableChooser.GetSelected() return as?
It returns a void*, which you cast to a Whatever* that you passed into AddObject (in your case, Command*)
Code:
It's not a memory leak since you'd never normally delete your auto commands anyway. |
Re: What does SendableChooser.GetSelected() return as?
Quote:
|
| All times are GMT -5. The time now is 10:25 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi