Skip to content
Snippets Groups Projects
Commit 580aacf1 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

add cancel in actionsheet

parent d07ffae0
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,8 @@ ...@@ -67,6 +67,8 @@
std::vector<std::string> choices = string[0].getChoices(); std::vector<std::string> choices = string[0].getChoices();
for(int i=0;i<choices.size();i++) for(int i=0;i<choices.size();i++)
[popupSelectValue addButtonWithTitle:[NSString stringWithFormat:@"%s", choices[i].c_str()]]; [popupSelectValue addButtonWithTitle:[NSString stringWithFormat:@"%s", choices[i].c_str()]];
[popupSelectValue addButtonWithTitle:@"Cancel"];
[popupSelectValue setCancelButtonIndex:popupSelectValue.numberOfButtons - 1];
[popupSelectValue showInView:button]; [popupSelectValue showInView:button];
} }
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
...@@ -74,6 +76,7 @@ ...@@ -74,6 +76,7 @@
std::vector<onelab::string> string; std::vector<onelab::string> string;
onelab::server::instance()->get(string,[name UTF8String]); onelab::server::instance()->get(string,[name UTF8String]);
if(string.size() < 1) return; if(string.size() < 1) return;
if(buttonIndex > string[0].getChoices().size() - 1) return; // cancel
std::string selected = string[0].getChoices()[buttonIndex]; std::string selected = string[0].getChoices()[buttonIndex];
string[0].setValue(selected); string[0].setValue(selected);
onelab::server::instance()->set(string[0]); onelab::server::instance()->set(string[0]);
...@@ -129,6 +132,8 @@ ...@@ -129,6 +132,8 @@
std::vector<double> choices = number[0].getChoices(); std::vector<double> choices = number[0].getChoices();
for(int i=0;i<choices.size();i++) for(int i=0;i<choices.size();i++)
[popupSelectValue addButtonWithTitle:[NSString stringWithFormat:@"%s", number[0].getValueLabel(choices[i]).c_str()]]; [popupSelectValue addButtonWithTitle:[NSString stringWithFormat:@"%s", number[0].getValueLabel(choices[i]).c_str()]];
[popupSelectValue addButtonWithTitle:@"Cancel"];
[popupSelectValue setCancelButtonIndex:popupSelectValue.numberOfButtons - 1];
[popupSelectValue showInView:button]; [popupSelectValue showInView:button];
} }
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
...@@ -136,6 +141,7 @@ ...@@ -136,6 +141,7 @@
std::vector<onelab::number> number; std::vector<onelab::number> number;
onelab::server::instance()->get(number,[name UTF8String]); onelab::server::instance()->get(number,[name UTF8String]);
if(number.size() < 1) return; if(number.size() < 1) return;
if(buttonIndex > number[0].getChoices().size() - 1) return; // cancel
double selected = number[0].getChoices()[buttonIndex]; double selected = number[0].getChoices()[buttonIndex];
number[0].setValue(selected); number[0].setValue(selected);
onelab::server::instance()->set(number[0]); onelab::server::instance()->set(number[0]);
......
...@@ -108,13 +108,13 @@ ...@@ -108,13 +108,13 @@
ParameterNumberCheckbox *param = [[ParameterNumberCheckbox alloc] initWithNumber:p]; ParameterNumberCheckbox *param = [[ParameterNumberCheckbox alloc] initWithNumber:p];
[section addObject:param]; [section addObject:param];
} }
else if(p.getStep() == 0) { // text box
ParameterNumberTextbox *param = [[ParameterNumberTextbox alloc] initWithNumber:p];
[section addObject:param];
}
else if(p.getStep() == 1) { // stepper else if(p.getStep() == 1) { // stepper
ParameterNumberStepper *param = [[ParameterNumberStepper alloc] initWithNumber:p]; ParameterNumberStepper *param = [[ParameterNumberStepper alloc] initWithNumber:p];
[section addObject:param]; [section addObject:param];
}
else if(p.getMin() == p.getMax()) { // text box, since no range
ParameterNumberTextbox *param = [[ParameterNumberTextbox alloc] initWithNumber:p];
[section addObject:param];
} }
else { else {
ParameterNumberRange *param = [[ParameterNumberRange alloc] initWithNumber:p]; ParameterNumberRange *param = [[ParameterNumberRange alloc] initWithNumber:p];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment