[resolved] widget.NewButton only returning press

Hi everyone, this is my first post here so I hope you can excuse any mistakes I make. I am currently using the “widget” module for scrolling and buttons, but I cannot get a button press to return anything but “press”. I am also using the “director” module. Here is a snip of the code I am using:

  
new = function ( params )  
  
local widget = require "widget"  
  
local scrollView = widget.newScrollView {  
 width = 320,  
 height = 480,  
 scrollWidth = 320,  
 scrollHeight = 1000  
}  
  
local contactUsTouch = function( event )  
 print( event.phase )  
end  
  
local contactUs = widget.newButton {  
 label = "Contact Us",  
 top = 0,  
 left = 0,  
 emboss = "true",  
 defaultColor = { 255, 0, 0 },  
 overColor = { 0, 255, 0 },  
 width = \_w \* .90, height = 50,  
 cornerRadius = 8,  
 onEvent = contactUsTouch  
}  
  
displayButtons:insert( contactUs )  
scrollView:insert( contactUs )  
  
displayMain:insert( displayButtons )  
displayMain:insert( scrollView )  
return displayMain  
  
end  

I think that should about get the point across. When I was using the “ui” 1.5 library, it would return the different event phases. Thoughts?

Sean [import]uid: 157382 topic_id: 29719 reply_id: 329719[/import]

Hi there. I’m having trouble making the option clickable and changing the scene. I have a menu.lua file that has two options, and if a user clicks on one of them it will send him to a separate lua file. Are there any suggestions I could have? [import]uid: 162639 topic_id: 29719 reply_id: 119305[/import]

Using the “director” module this is easily accomplishable. It works fine for me, but when I implement the widget.newScrollView my clicks no longer register. There is a post that speaks about passing the focus back to the scroller when you move the pointer more than 5 px:

http://www.coronalabs.com/blog/2012/01/10/new-more-flexible-scrollview-widget/

I implemented that, but am just having the issue with the clicks only returning “press” [import]uid: 157382 topic_id: 29719 reply_id: 119355[/import]

When I was able to put fresh eyes on it this morning, i noticed that I was setting the function with

local <variable> = function(event)

when it should have been

local function <variable>(event)

After I changed that (and added in return true before the last end of the function), it worked perfectly. [import]uid: 157382 topic_id: 29719 reply_id: 119356[/import]