Subscribe Bookmark RSS Feed

Delete a text box and a button from a lineup box

pauldeen

Community Trekker

Joined:

Oct 24, 2014

I'm trying to delete both the button itself and the associated text box before it. So when I cilck button nr 3 I want text nr 3 to also be deleted. Any ideas?

 

nr=5;
new window("Button test",
	Lineuplist=Lineup Box( N Col( 2 ),
		
	)
);
For(i=1,i<=nr,i++,
	Lineuplist << append(textbox("Text nr "||char(i)));
	Lineuplist << append(
		buttonbox("Button nr "||char(i),
			<< Set Function(
				Function({this},
					this << delete;
				)
			)
		);
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
thomasz

Community Trekker

Joined:

Mar 11, 2016

Solution

Here is a piece of code that works:

nr=5;
new window("Button test",
	Lineuplist=Lineup Box( N Col( 2 ),
		
	)
);
For(i=1,i<=nr,i++,
	Lineuplist << append(textbox("Text nr "||char(i)));
	Lineuplist << append(
		buttonbox("Button nr "||char(i),
			<< Set Function(
				Function({this},
					ps=this<<sib;
					par=this<<parent;
					buttonName=this<<get button name;
					buttonNo=regex(buttonName,".*?([0-9]*)$","\1");
					locator=eval insert("//TextBox[text()='Text nr ^buttonNo^']");
					textBox=par<<xpath(locator);
					textBox<<delete;
					this<<delete;
				)
			)
		);
	);
);
3 REPLIES
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

@pauldeen

nr=5;
new window("Button test",
	Lineuplist=Lineup Box( N Col( 2 ))
	      ); 
);
For(i=1,i<=nr,i++,
	Lineuplist << append(textbox("Text nr "||char(i)));
	Lineuplist << append(
		buttonbox("Button nr "||char(i),
			<< Set Function(
				Function({this},
					this << delete;
				)
			)
		);
	);
	Lineuplist[Text Box(i)] << delete ; // this is the piece of code which will do what you are after . Insert it where you delete the button 
);
Best
Uday
thomasz

Community Trekker

Joined:

Mar 11, 2016

Solution

Here is a piece of code that works:

nr=5;
new window("Button test",
	Lineuplist=Lineup Box( N Col( 2 ),
		
	)
);
For(i=1,i<=nr,i++,
	Lineuplist << append(textbox("Text nr "||char(i)));
	Lineuplist << append(
		buttonbox("Button nr "||char(i),
			<< Set Function(
				Function({this},
					ps=this<<sib;
					par=this<<parent;
					buttonName=this<<get button name;
					buttonNo=regex(buttonName,".*?([0-9]*)$","\1");
					locator=eval insert("//TextBox[text()='Text nr ^buttonNo^']");
					textBox=par<<xpath(locator);
					textBox<<delete;
					this<<delete;
				)
			)
		);
	);
);
pauldeen

Community Trekker

Joined:

Oct 24, 2014

Thanks!