Eric Welander
Eric Welander

Reputation: 560

Trying to add event to .ShouldReturn on an Entry Element

I am trying to add an event that's triggered by the TextFieldShouldReturn inside a Monotouch.Dialog entry element. I am currently trying to attach an event like so:

   //create the entry element
   EntryElement newEntry = new EntryElement(thisQuestion.Text, "tap to type", null);
   //add should return
   newEntry.ShouldReturn(addAnswerToSurvey(newEntry.Value, thisQuestion.Index));
   //add the entry to the section
   aSection.Add(newEntry);

I get an error back on build: 'MonoTouch.Dialog.EntryElement.ShouldReturn' can only appear on the left hand side of += or -= when used outside of the type 'MonoTouch.Dialog.EntryElement' (CS0070)

I have heard of people not being able to get data out of Monotouch.Dialog statements, and that's seems to be what this error might suggest. So... Is is possible to implement the text field should return delegate on an entry element, if so, how? If not, is it just there because the entry element contains a text field?

Upvotes: 0

Views: 713

Answers (1)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

Eric, you need to use:

newEntry.ShouldReturn += () => { ... }

Upvotes: 1

Related Questions