Swipe & Slide through pages, like a book reader (iPad)

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Swipe & Slide through pages, like a book reader (iPad)

Post by GeorgeMcGinn »

Hi,

Thanks - this is all I need.

George
Dav wrote:George, I worked on the slider code for this program separately. Since the slider code is something you are interested in, here is just the slider control part of the program for you to have.

- Dav

Code: Select all

'slidermarks.txt
'Shows how to make a slider with set marks.
'Used for navigating book pages in a program.
'Coded by Dav, JAN/2017

option base 1

sw=screen_width()

maxpg =4 'number of points to mark slider (pages)

'since the slider will be the screen width, we
'will divide screen width by num of pages.
'you should instead divide slider width by num
'of pages in your program.
sv=sw/maxpg   'slider width / total num of pages

'get point values for each mark placement
dim sg(maxpg)
for t = 1 to maxpg
  sg(t)=sv*t  'pixel value...
next t

'create a slider to use
slider 0 value 0/sw at 0,100 size sw

'button to show info only
button "1" text "0" at 10,10

do
   'if user moved slider...
   if slider_changed("0")then 

     'get current slider value
     slv=slider_value("0")*sw

     'find nearest mark based on slider value
     dispg=1
     for t = 1 to maxpg
       if slv> sg(t) then dispg=dispg+1
     next t

     '===== notes =================================
     'dispg is the current mark (page) slider is at
     'sg(dispg) is the point value for that mark.
     '
     'now you know the current page (dispg) you can
     'do something like if dispg=1 then goto page 1
     '=============================================

     'update button info
     a$="PAGE "&dispg&" ("&str$(sg(dispg))&")"
     a$=a$&", slider value:"&slv
     button "1" text a$ at 10,10

   end if
until 0

George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

Post Reply