Table Listener Name for native.newTextField()

What is the name of the Table Listener for native.newTextField() ? [import]uid: 6928 topic_id: 1335 reply_id: 301335[/import]

Listeners can be added for runtime events, targeted events, and touch events.

https://developer.anscamobile.com/content/events-and-listeners

What are you trying to do? Could you include some code?

-Gilbert [import]uid: 5917 topic_id: 1335 reply_id: 3625[/import]

I want to know the name of the table listener for “native.newTextField()” and I believe that this is a precise question!

Examples for other table listeners are:

The table listener name for “enterFrame” events is “enterFrame”…

The table listener name for “media.show()” function is “completion”…

The table listener name for “transition.to()” “onComplete” parameter… is “onComplete”

The table listener name for “applicationExit” events is “system”
Example code is:

function foo:NAMEISEARCH(event)
– do something on event phases
end

function foo:SetupTextfield()
self.textfield=native.newTextField(0,0,100,30,self)
end
Consider me searching all available docs and example code you provide and making a considerable amount of “guestimation” before I ask a question :slight_smile: [import]uid: 6928 topic_id: 1335 reply_id: 3626[/import]

@Oderwat: Having a bad day? Imho everything that can do with the native text field is documented in the api refernce or shown inside the samples. [import]uid: 5712 topic_id: 1335 reply_id: 3632[/import]

I asked a very clear question and have yet to get an answer. If that is so easy why don’t you tell me the name needed?

If there is none implemented, it is different to all other events which have a documented table listener.

Of course am I able to use a function handler instead. But this is less elegant and not needed for all the other events. [import]uid: 6928 topic_id: 1335 reply_id: 3633[/import]

Cause I just explained how table listeners work I am coming back here…

So is there somebody giving me the answer to my question please? [import]uid: 6928 topic_id: 1335 reply_id: 3823[/import]

I think you might be looking for the event phases, so you can handle events in the text field. Correct?

Listen for “began”, “ended”, or “submitted” as shown below.

[code]function fieldHandler( event )

if ( “began” == event.phase ) then
– This is the “keyboard has appeared” event
– In some cases you may want to adjust the interface when the keyboard appears.

elseif ( “ended” == event.phase ) then
– This event is called when the user stops editing a field: for example, when they touch a different field

elseif ( “submitted” == event.phase ) then
– This event occurs when the user presses the “return” key (if available) on the onscreen keyboard

– Hide keyboard
native.setKeyboardFocus( nil )
end

end[/code]
In the sample code provided with Corona, there’s an example of this in SampleCode/iPhone/Interface/NativeKeyboard/
[import]uid: 5917 topic_id: 1335 reply_id: 3824[/import]

Event phases are documented here: http://developer.anscamobile.com/content/native-ui-features#Listening_for_Keyboard_Events [import]uid: 5917 topic_id: 1335 reply_id: 3825[/import]

@Gilbert

Sorry if I sound impatient… but no I do not want to know anything which is obvious and documented.
I am using objects… so I have to know what the name of the table listener is…

Your example uses a function handler… and it is pretty clear how that works.

I am talking about this:

function object:nameIAskFor(event)  
 if(event.phase=="submitted") then  
 -- work on it..  
 print("The Text is: "..self.textfield.text)  
 end  
end  
  
function object:openKeyboard()  
 self.textfield=native.newTextField( 0, 0, 320, 30, self)   
end  

If “enter” is pressed the TextField calls the listener… this has to be a table listener in my example … and I do not know what name to use for the corresponding method in the object (table).

Normally you documentation states what the name of a table listener is… most of the time it is the same name as “event.name” contains for the function handler.

The documentation of native.newTextField() does not state the name of the method it calls if you specify a table as parameter for the listener when calling the function.

I wonder if this is a language problem… I was sure that my question is clear and esp. in this context. [import]uid: 6928 topic_id: 1335 reply_id: 3827[/import]

Sorry I did not understand at first. I think your question is clear now.

You’re right, this is not documented. I’ve asked one of the other developers to see if he can get the answer for you.

[import]uid: 5917 topic_id: 1335 reply_id: 3831[/import]

Yes, this does not seem to be documented! But the event name should be “userInput”.

I’ll add this to the online documentation now. [import]uid: 3007 topic_id: 1335 reply_id: 3832[/import]

Thank you!

It works and I just could integrate it in my app… feels much more user friendly now :slight_smile: [import]uid: 6928 topic_id: 1335 reply_id: 3838[/import]