Startseite › Foren › Deutsches LiveCode-Forum › Problem mit mobile Scroller › Antwort auf: Problem mit mobile Scroller
November 9, 2018 um 22:20 Uhr
#8474
Hallo Klaus,
Das Löschen des Scrollers hatte ich auch schon eingebaut. Habe den Scrollern auch verschiedene Namen gegeben. Jetzt funktioniert genau 1x den Stack wechseln. Dann nicht mehr. Hier nochmal der gesamte Code:
Stack2 / Card b1:
on preOpenCard
global sScrollerID
global tScrollerRect, tContentRect, vOffset
BewegeScroller
end preOpenCard
on closeCard
// Delete the scroller
global sScrollerID
if environment() is not "mobile" then exit closeCard
mobileControlDelete sScrollerID
end closeCard
Stack2:
global sScrollerID
global tScrollerRect, tContentRect, vOffset
on BewegeScroller
// Only create a scroller on a mobile device
if environment() is not "mobile" then exit BewegeScroller
put the rect of group "scrollArea" into tScrollerRect
put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect
// Create the scroller control
mobileControlCreate "scroller", "my_scroller1"
put the result into ssScrollerID
// Set the properties of the scroller
mobileControlSet "my_scroller1", "rect", tScrollerRect
mobileControlSet "my_scroller1", "contentRect", tContentRect
mobileControlSet "my_scroller1", "visible", true
mobileControlSet "my_scroller1", "scrollingEnabled", true
mobileControlSet "my_scroller1", "vIndicator", true
mobileControlSet "my_scroller1", "vscroll", 0
end BewegeScroller
on scrollerDidScroll hOffset, vOffset
// When the user scrolls move the displayed content
set the vScroll of group "scrollArea" to vOffset
end scrollerDidScroll
Stack3 / card c1:
on preOpenCard
global sScrollerID
global tScrollerRect, tContentRect, vOffset
BewegeScroller
end preOpenCard
on closeCard
// Delete the scroller
global sScrollerID
if environment() is not "mobile" then exit closeCard
mobileControlDelete sScrollerID
end closeCard
Stack3:
global sScrollerID
global tScrollerRect, tContentRect, vOffset
on BewegeScroller
// Only create a scroller on a mobile device
if environment() is not "mobile" then exit BewegeScroller
put the rect of group "scrollArea" into tScrollerRect
put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect
// Create the scroller control
mobileControlCreate "scroller", "myscroller_2"
put the result into ssScrollerID
// Set the properties of the scroller
mobileControlSet "myscroller_2", "rect", tScrollerRect
mobileControlSet "myscroller_2", "contentRect", tContentRect
mobileControlSet "myscroller_2", "visible", true
mobileControlSet "myscroller_2", "scrollingEnabled", true
mobileControlSet "myscroller_2", "vIndicator", true
mobileControlSet "myscroller_2", "vscroll", 0
end BewegeScroller
on scrollerDidScroll hOffset, vOffset
// When the user scrolls move the displayed content
set the vScroll of group "scrollArea" to vOffset
end scrollerDidScroll
Danke
Walter