Scrolling Group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Scrolling Group

Post by Not a lot of thought » Mon Aug 24, 2015 3:26 am

Not exactly sure what is causing this issue, but I'm trying to use the standard method of creating a scrolling group by using the mousedown and mouseup handlers on a group. I tried setting this on a stack level command worked for the horizontal, but it isn't actually scrolling, its just moving an object. Regardless, I moved it down to the group level to see if I could get a better response. No dice. I tested the commands and it seems that my mousedown handler is received by the group ( showing up a true value in a test field for that handler ). However, the mouseUP handler only is received when it is on a few specific objects within that group (none of which actually have scripts) and it is only returned whenever the mouseDown and mouseUp handlers are received by the same object. I'm not exactly sure what might be causing this issue. I'm sure it's just something that I am overlooking, but I can't seem to figure it out.

What I am creating:
Essentially I have a group of objects displaying information about a given object but it displays a larger array of data than can fit on the screen so I need the group to be able to scroll down and up to access the information.

Code (wherever there is a put something into field "test1" that is just a validation that the command is being run) The breakdown starts at the On MouseUp:
global sStartH, sStartV

on mouseDown
put the mouseV into sStartV
put "mousedown" into field "test1"
end mouseDown

on mouseUp
put "mouseUp" into field "test1"
if abs(the mouseV - sStartV) > 100 then
if the mouseV - sStartV >0 then
put "true" into field "test1"
else if the mouseV - sStartV <0 then
put "truedown" into field "test1"
end if
end if
put "mouseUp4" into field "test1"
end mouseUp


on swipedown
put the mouseV - sStartV into SwipeDownDist
set the vScroll of grp "Scroll_group id 5263" to SwipeDownDist
put "true" into field "test1"
end swipedown

on swipeUp
put the mouseV - sStartV into SwipeUpDist
set the vScroll of grp "Scroll_group id 5263" to SwipeUpDist
put "true" into field "test1"
end swipeUp

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Scrolling Group

Post by Klaus » Mon Aug 24, 2015 11:22 am

Oh, come on!
Even with a username like yours, the name of this forum can not be misunderstood this much! 8)

Moving this to the beginners section...

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Scrolling Group

Post by Not a lot of thought » Mon Aug 24, 2015 11:31 am

Yeah. I didn't see the User...thought it said Groups and Gatherings. I just logged on to move it.

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm
Location: Greece

Re: Scrolling Group

Post by zaxos » Mon Aug 24, 2015 3:34 pm

Not sure what you where trying to do there with the mouseUp handler, anyway this will do what you want i tested it and its working:

Code: Select all

local sStartV

on mouseMove
   if sStartV <> empty then
      if sStartV < the mouseV then
         swipeUp
      else
         swipeDown
      end if 
   end if
end mouseMove

on mouseUp
   put empty into sStartV
end mouseUp

on mouseDown
put the mouseV into sStartV
end mouseDown

on swipedown
put the mouseV - sStartV into SwipeDownDist
set the vScroll of grp 1 to SwipeDownDist
end swipedown

on swipeUp
put the mouseV - sStartV into SwipeUpDist
set the vScroll of grp 1 to SwipeUpDist
end swipeUp
Knowledge is meant to be shared.

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Scrolling Group

Post by Klaus » Mon Aug 24, 2015 6:19 pm

Hi guys,

no need to poll the mouse several times inside of the handlers!

"mousemove X,Y" goes with 2 parameters, so we can pass this
to the swipeXXX handlers a a parameter:

Code: Select all

local sStartV
on mouseMove X,Y
   if sStartV <> empty then
      if sStartV < Y then
         swipeUp Y
      else
         swipeDown Y
      end if 
   end if
end mouseMove

on mouseUp
   put empty into sStartV
end mouseUp

on mouseDown
  put the mouseV into sStartV
end mouseDown

on swipedown Y
  put Y - sStartV into SwipeDownDist
  set the vScroll of grp 1 to SwipeDownDist
end swipedown

on swipeUp Y
  put Y - sStartV into SwipeUpDist
  set the vScroll of grp 1 to SwipeUpDist
end swipeUp
:D


Best

Klaus

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Scrolling Group

Post by Not a lot of thought » Tue Aug 25, 2015 11:21 am

Klaus:
That worked, but it doesn't scroll the whole distance down the group. It only goes approximately a quarter of the way. When you try to move it further by going to the top of the group again (moving the cursor outside of the range of the group going to the top) and swipe down more it pops back up to the top of the group?!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”