I recently wanted to write an app (principally for running on a touchscreen) which allowed the user to select between two 'pages' of information. I could have used a mouse-click or tap to toggle between them, but decided that it would be nicer to use a swipe gesture (common in mobile apps) to scroll between the pages 'smoothly'.
This turned out to be very easy, by using the @ox% system variable (horizontal offset) to do the scrolling (it's smoother in reality than the video suggests):
https://www.youtube.com/watch?v=qGVkEfgYUTA
Swipe to change displayed page
Re: Swipe to change displayed page
I've now expanded that to three pages, which is the maximum number of 640-pixel-wide pages that will fit side-by-side in the default canvas width of 1920 pixels in BB4W or 2048 pixels in BBCSDL. This is the code I used, it works very nicely:Hated Moron wrote: ↑Mon 30 May 2022, 17:56 I recently wanted to write an app (principally for running on a touchscreen) which allowed the user to select between two 'pages' of information.
Code: Select all
MOUSE X%, Y%, B%
X% -= @ox% * 2
IF B% THEN
xvel = 0
IF drag% THEN
xpos -= (X% - lastx%) / 2
ELSE
startx% = X%
startt% = TIME
drag% = TRUE
ENDIF
ELSE
IF drag% THEN
xvel = (lastx% - startx%) / (TIME - startt%)
drag% = FALSE
ELSE
ENDIF
ENDIF
lastx% = X%
xpos -= xvel
IF xpos < 0 xpos = 0 : xvel = 0
IF B% = 0 IF xpos > 640 EOR xpos + xvel >= 640 xpos = 640 : xvel = 0
IF xpos > 1280 xpos = 1280 : xvel = 0
@ox% = xpos
Re: Swipe to change displayed page
On Sun, Jul 3, 2022 at 09:58 AM, Jeremy Nicoll wrote (cross-posted from Discussion Group):
For the record, I have made considerable efforts to get the code formatting issue fixed. I would refer anybody genuinely interested to read this thread at the phpBB forum where you will see that I have reported it, raised it formally at their issue tracking site, and even offered to pay for a fix.
It is not straightforward to "find some way to get the code to arrive at groups.io in a comprehensible manner" or to arrange that "the code didn't get forwarded at all". phpBB is, as the name suggests, coded in php; only somebody familiar with php and with the forum software would be in a position to make the kinds of change suggested, which is precisely why I posted to their forum.
Do not be surprised if you never see any posts from me again.
This post deliberately sets out to insult and demean by describing me as "he/it/whatever", emphasising that the writer does not consider that I am even deserving of being treated as a human being. Never has my choice of 'hated moron' as a nickname been more appropriate.This comment is not aimed at "Hated Moron"; it's just that it's his/it's (?)
posts that most often contain garbled code, so I'm responding to one
of them. I hope he/it/whatever understands that...
The "CODE" blocks in all of these posts viewed via groups.io are completely
incomprehensible...
It /is/ possible to use the URL link that is in the posts, as seen the way I see
them, to go to the https://www.bbcbasic.co.uk/forum/... forum and see the
post properly.
But can't someone find some way to get the code to arrive at groups.io in
a comprehensible manner? If not, it would be better if the code didn't get
forwarded at all, and the mails just said something like "To see sample code
please click the following link".
Jeremy Nicoll - my opinions are my own.
For the record, I have made considerable efforts to get the code formatting issue fixed. I would refer anybody genuinely interested to read this thread at the phpBB forum where you will see that I have reported it, raised it formally at their issue tracking site, and even offered to pay for a fix.
It is not straightforward to "find some way to get the code to arrive at groups.io in a comprehensible manner" or to arrange that "the code didn't get forwarded at all". phpBB is, as the name suggests, coded in php; only somebody familiar with php and with the forum software would be in a position to make the kinds of change suggested, which is precisely why I posted to their forum.
Do not be surprised if you never see any posts from me again.