文本框 Corona(lua)发送字符

我想知道如何实现一个“搜索栏”,用户在其中输入文本,当用户点击搜索按钮或按 Enter 键后,该信息将被发送。

local campoBusqueda = native.newTextField(50, 50, 300, 25, onButtonRelease)
点赞
用户2333874
用户2333874

这应该会有所帮助: http://www.coronalabs.com/blog/2012/02/07/tutorial-text-input-with-native-ui/

信息将在提交事件上提交。

2013-05-23 00:42:02
用户889843
用户889843

我提供给您我在我的代码中使用的代码,但您可以根据需要使用这个代码 -

local 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

textField = native.newTextField( 75, 150, 165, 30, fieldHandler )

textField.font = native.newFont( native.systemFontBold, 24 )

textField.inputType = "Name"

group:insert(textField)

我希望它对您有所帮助..

2013-05-23 04:35:26