Scrolling a group with the Mouse Wheel

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
nacnud
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3
Joined: Mon Jan 23, 2012 6:52 am

Scrolling a group with the Mouse Wheel

Post by nacnud » Wed Oct 10, 2012 7:30 am

Hi All,

I have been looking for an answer on how to scroll a group with the mouse scroll wheel.
I have a group of elements that is bigger than the card. I can scroll the group using the scroll bar on the left hand side but i have not been able to get it to scroll using the mouse wheel.
I have tried using the rawkeydown command but it only seems to be controlling fields and not the group.

If anyone could help it would be greatly appreciated.

Regards
Chris

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Scrolling a group with the Mouse Wheel

Post by bn » Wed Oct 10, 2012 9:23 am

Hi Chris,

put this handler into the script of the group that has its lockLoc set to true:

Code: Select all

on rawKeyDown pKey
   switch pKey
      case 65309
         set the vScroll of me to the vScroll of me - 5
         break
      case 65308
         set the vScroll of me to the vScroll of me + 5
         break
      case 65311
         set the hScroll of me to the hScroll of me - 5
         break
      case 65310
         set the hScroll of me to the hScroll of me +5
         break
      default
         pass rawKeyDown
   end switch
end rawKeyDown
You don't have to show the vertical/horizontal scrollbars for this to work.
if works on the mac, should also work on windows.

Kind regards
Bernd

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Scrolling a group with the Mouse Wheel

Post by mrcoollion » Mon May 25, 2020 4:37 pm

This does not work very well on Windows. Some times it does but most of the times it stops scrolling and or does not even react on the mouse wheel.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Scrolling a group with the Mouse Wheel

Post by richmond62 » Mon May 25, 2020 7:53 pm

And, what happens after I've pressed down on my mouse wheel and then scroll back and forwards a spot?

Err . . . hang about . . . that's odd, something I've not noticed before:

when I scroll the mouse I get 65308 or 65309 . . . so a rawKeyDown signal is received NOT when I press down on the wheel,
but only when I wiggle the thing.

OK . . .so how does the stack know any difference between when I scroll "1 tad" and "2 tads"?

I also wonder why this code in a fieldScript does not work:

Code: Select all

on mouseUp
   put the vScroll of me
end mouseUp

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Scrolling a group with the Mouse Wheel

Post by bogs » Mon May 25, 2020 8:49 pm

Well, I don't pretend to know about the .... ummm... wiggly jiggly question :twisted: but as to this -
richmond62 wrote:
Mon May 25, 2020 7:53 pm
I also wonder why this code in a fieldScript does not work:
unless the field is locked and transversal is off, you will not see a mouseUp fire in a field, it is ignored.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Scrolling a group with the Mouse Wheel

Post by richmond62 » Mon May 25, 2020 9:09 pm

Thanks for the heads up! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Scrolling a group with the Mouse Wheel

Post by richmond62 » Mon May 25, 2020 9:23 pm

Either I've been a bit stupid, or I've merely missed something . . .
-
Screenshot 2020-05-25 at 23.20.04.png
-
I made a stack 400 x 400, and put a scrolling field on that card with a vertical scroll,
and made that field 440 x 440.
-
Screenshot 2020-05-25 at 23.24.37.png
-
I can scroll that field with my mouse wheel . . . "just like that" . . . no scripting, "no nothing"

what did I miss?
Attachments
Scroller Ball.livecode.zip
Here's the stack.
(1.02 KiB) Downloaded 227 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Scrolling a group with the Mouse Wheel

Post by richmond62 » Mon May 25, 2020 9:38 pm

Err . . .
how to scroll a group with the mouse scroll wheel
My emphasis.

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Scrolling a group with the Mouse Wheel

Post by mrcoollion » Sun Jun 07, 2020 12:53 pm

mrcoollion wrote:
Mon May 25, 2020 4:37 pm
This does not work very well on Windows. Some times it does but most of the times it stops scrolling and or does not even react on the mouse wheel.
I found a good working answer on my own remark that also works for scrolling a group with the Mouse Wheel. After placing a graphic into the group as its background and size it so that it fills the group scrolling works as expected.
sturgis wrote:
Tue Apr 30, 2013 11:16 pm
Also be aware that groups behave strangely with many messages. If you have 3 buttons in your group and move the mouse into the group but don't point at a control, there is no mouseEnter. Once you touch a control the mouseEnter message is sent.

One way around this is to put a graphic into the group as its background and size it so that it fills the group.
Then when you enter the group with the mouse there is always a control there.

Regards,

Paul

Post Reply