我想知道如何实现一个“搜索栏”,用户在其中编写文本,并且在用户单击按钮搜索或按 Enter 后将发送此信息。
local campoBusqueda = native.newTextField( 50, 50, 300, 25 , onButtonRelease )
这应该会有所帮助: http: //www.coronalabs.com/blog/2012/02/07/tutorial-text-input-with-native-ui/
该信息将在提交的事件上提交。
我正在为您提供我在代码中使用的代码,但您可以根据需要使用此代码 -
本地函数 fieldHandler( 事件 )
如果(“开始”== event.phase)那么
-- This is the "keyboard has appeared" event
-- In some cases you may want to adjust the interface when the keyboard appears.
elseif ( "结束" == event.phase ) 然后
-- This event is called when the user stops editing a field: for example, when they touch a different field
elseif ( "提交" == event.phase ) 然后
-- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard
-- Hide keyboard
native.setKeyboardFocus( nil )
end
结尾
textField = native.newTextField( 75, 150, 165, 30, fieldHandler )
textField.font = native.newFont(native.systemFontBold, 24)
textField.inputType = "名称"
组:插入(文本字段)
我希望,它会帮助你..