Can anyone tell me is it is possible to have buttons inside a scrollview object??
I tried to develop that on android but i had some problems… the buttons did not work properly… [import]uid: 185094 topic_id: 33415 reply_id: 333415[/import]
Are you using widget.newButton or some other way of making the buttons? [import]uid: 199310 topic_id: 33415 reply_id: 132802[/import]
i tried both ways… i inserted buttons in scrollview sucessfuly. The problem is that in some android version the project does not work properly. The problem is on touch event of the buttons. when i touch a button , the program listens only a moved phase of that event… The problem exists using widget.newButton or i using an image object for constructing buttons… [import]uid: 185094 topic_id: 33415 reply_id: 132890[/import]
this is some code…
[lua]
Group1 = display.newGroup();
Group2 = display.newGroup();
Group3 = display.newGroup();
Group4 = display.newGroup();
local scrollView = widget.newScrollView{
top = 0,
width = 320,
height = 459,
scrollWidth = 810,
scrollHeight = 459,
hideBackground=true,
frinction=1.2,
maskFile=“mask2.png”
}
scrollView.content.verticalScrollDisabled = true
scrollView.content.horizontalScrollDisabled= false
scrollView.isHitTestMasked = true;
local hotel = display.newImageRect(“images/menu/hotel.png”, 90, 180)
Group1:insert(hotel);
Group1.isHitTestMasked = true;
Group1:setReferencePoint(display.CenterReferencePoint)
Group1.x=hotel.width/2 +10
Group1.y=350
function Group1:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group1:remove(hotel);
hotel = display.newImageRect(“images/menu/hotel_hover.png”,90,180);
Group1:insert(hotel);
display.getCurrentStage():setFocus(event.target,event.id);
event.target.isFocus = true
elseif event.target.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus(event)
Group1:remove(hotel);
hotel = display.newImageRect(“images/menu/hotel.png”,90,180);
Group1:insert(hotel);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus(event.target,nil);
event.target.isFocus = false
storyboard.gotoScene(“hotel”);
end
end
return true
end
Group1:addEventListener( “touch”, Group1 )
scrollView:insert(Group1)
local rooms = display.newImageRect(“images/menu/room.png”, 90, 180)
Group2:insert(rooms);
Group2:setReferencePoint(display.CenterReferencePoint)
Group2.x=Group1.x+hotel.width +10
Group2.y=350
function Group2:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group2:remove(rooms);
rooms = display.newImageRect(“images/menu/room_hover.png”,90,180);
Group2:insert(rooms);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group2:remove(rooms);
rooms = display.newImageRect(“images/menu/room.png”,90,180);
Group2:insert(rooms);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“rooms”);
end
end
return true
end
Group2:addEventListener( “touch”, Group2 )
scrollView:insert(Group2)
local news = display.newImageRect(“images/menu/news.png”, 90, 180)
Group3:insert(news);
Group3:setReferencePoint(display.CenterReferencePoint)
Group3.x=Group2.x+hotel.width +10
Group3.y=350
function Group3:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group3:remove(news);
news = display.newImageRect(“images/menu/news_hover.png”,90,180);
Group3:insert(news);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group3:remove(news);
news = display.newImageRect(“images/menu/news.png”,90,180);
Group3:insert(news);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“nea”);
end
end
return true
end
Group3:addEventListener( “touch”, Group3 )
scrollView:insert(Group3)
local topothesia = display.newImageRect(“images/menu/topothesia.png”, 90, 180)
Group4:insert(topothesia);
Group4:setReferencePoint(display.CenterReferencePoint)
Group4.x=Group3.x+hotel.width +10
Group4.y=350
function Group4:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group4:remove(topothesia);
topothesia = display.newImageRect(“images/menu/topothesia_hover.png”,90,180);
Group4:insert(topothesia);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group4:remove(topothesia);
topothesia = display.newImageRect(“images/menu/topothesia.png”,90,180);
Group4:insert(topothesia);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“scene1”);
end
end
return true
end
Group4:addEventListener( “touch”, Group4 )
scrollView:insert(Group4)
group:insert(scrollView); [import]uid: 185094 topic_id: 33415 reply_id: 132891[/import]
Are you using widget.newButton or some other way of making the buttons? [import]uid: 199310 topic_id: 33415 reply_id: 132802[/import]
i tried both ways… i inserted buttons in scrollview sucessfuly. The problem is that in some android version the project does not work properly. The problem is on touch event of the buttons. when i touch a button , the program listens only a moved phase of that event… The problem exists using widget.newButton or i using an image object for constructing buttons… [import]uid: 185094 topic_id: 33415 reply_id: 132890[/import]
this is some code…
[lua]
Group1 = display.newGroup();
Group2 = display.newGroup();
Group3 = display.newGroup();
Group4 = display.newGroup();
local scrollView = widget.newScrollView{
top = 0,
width = 320,
height = 459,
scrollWidth = 810,
scrollHeight = 459,
hideBackground=true,
frinction=1.2,
maskFile=“mask2.png”
}
scrollView.content.verticalScrollDisabled = true
scrollView.content.horizontalScrollDisabled= false
scrollView.isHitTestMasked = true;
local hotel = display.newImageRect(“images/menu/hotel.png”, 90, 180)
Group1:insert(hotel);
Group1.isHitTestMasked = true;
Group1:setReferencePoint(display.CenterReferencePoint)
Group1.x=hotel.width/2 +10
Group1.y=350
function Group1:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group1:remove(hotel);
hotel = display.newImageRect(“images/menu/hotel_hover.png”,90,180);
Group1:insert(hotel);
display.getCurrentStage():setFocus(event.target,event.id);
event.target.isFocus = true
elseif event.target.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus(event)
Group1:remove(hotel);
hotel = display.newImageRect(“images/menu/hotel.png”,90,180);
Group1:insert(hotel);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus(event.target,nil);
event.target.isFocus = false
storyboard.gotoScene(“hotel”);
end
end
return true
end
Group1:addEventListener( “touch”, Group1 )
scrollView:insert(Group1)
local rooms = display.newImageRect(“images/menu/room.png”, 90, 180)
Group2:insert(rooms);
Group2:setReferencePoint(display.CenterReferencePoint)
Group2.x=Group1.x+hotel.width +10
Group2.y=350
function Group2:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group2:remove(rooms);
rooms = display.newImageRect(“images/menu/room_hover.png”,90,180);
Group2:insert(rooms);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group2:remove(rooms);
rooms = display.newImageRect(“images/menu/room.png”,90,180);
Group2:insert(rooms);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“rooms”);
end
end
return true
end
Group2:addEventListener( “touch”, Group2 )
scrollView:insert(Group2)
local news = display.newImageRect(“images/menu/news.png”, 90, 180)
Group3:insert(news);
Group3:setReferencePoint(display.CenterReferencePoint)
Group3.x=Group2.x+hotel.width +10
Group3.y=350
function Group3:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group3:remove(news);
news = display.newImageRect(“images/menu/news_hover.png”,90,180);
Group3:insert(news);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group3:remove(news);
news = display.newImageRect(“images/menu/news.png”,90,180);
Group3:insert(news);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“nea”);
end
end
return true
end
Group3:addEventListener( “touch”, Group3 )
scrollView:insert(Group3)
local topothesia = display.newImageRect(“images/menu/topothesia.png”, 90, 180)
Group4:insert(topothesia);
Group4:setReferencePoint(display.CenterReferencePoint)
Group4.x=Group3.x+hotel.width +10
Group4.y=350
function Group4:touch(event)
if event.phase == “began” then
print( “begin phase” )
Group4:remove(topothesia);
topothesia = display.newImageRect(“images/menu/topothesia_hover.png”,90,180);
Group4:insert(topothesia);
display.getCurrentStage():setFocus( self )
self.isFocus = true
elseif self.isFocus then
if event.phase == “moved” then
print( “moved phase” )
scrollView:takeFocus( event )
Group4:remove(topothesia);
topothesia = display.newImageRect(“images/menu/topothesia.png”,90,180);
Group4:insert(topothesia);
elseif event.phase == “ended” or event.phase == “cancelled” then
print( “ended phase” )
display.getCurrentStage():setFocus( nil )
self.isFocus = false
storyboard.gotoScene(“scene1”);
end
end
return true
end
Group4:addEventListener( “touch”, Group4 )
scrollView:insert(Group4)
group:insert(scrollView); [import]uid: 185094 topic_id: 33415 reply_id: 132891[/import]
its the 7nth day that i am stuck in that problem … i am sure this is a corona bug and i sent them a bug report, but none from corona staf tried to help me… I am realy very disapointed… [import]uid: 185094 topic_id: 33415 reply_id: 133675[/import]
its the 7nth day that i am stuck in that problem … i am sure this is a corona bug and i sent them a bug report, but none from corona staf tried to help me… I am realy very disapointed… [import]uid: 185094 topic_id: 33415 reply_id: 133675[/import]