scrolling with mouse wheel

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
blingbling
Posts: 11
Joined: Mon Apr 10, 2006 5:39 pm

scrolling with mouse wheel

Post by blingbling » Mon Apr 10, 2006 5:50 pm

I've been feeling overwhelmed by the email list, being a user of modest ability, with many other priorities. I'd been wishing that RR would set up a list better suited to users like me. So I guess it's only fair that I would post first.

BTW, many thanks to RR for setting up the new forum.javascript:emoticon(':)')

I have a long (tall) scrolling backgrounds on some cards, and on some cards I have a scrolling field, containing hudreds of lines. These are mostly clickable index fields.

I'd like to be able to scroll the backgrounds or fields in question with the mouse wheel -- vertically. On any given card, there would only be one field or bg I would want to scroll with the mouse wheel.

I can't figure out how to do it. The message watcher shows a scrollbardrag message when I move the mousewheel, but I don't know where to go from there.

Please advise,

Tim

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Re: scrolling with mouse wheel

Post by marielle » Mon Apr 10, 2006 7:04 pm

blingbling wrote:I'd like to be able to scroll the backgrounds or fields in question with the mouse wheel -- vertically. On any given card, there would only be one field or bg I would want to scroll with the mouse wheel.
This is supposed to work without any coding. Click on the field (in browse mode), then use the mousewheel, and this should gets you scroll up and down the textfield with the mousewheel.

Does it work differently on your platform (I just checked this behaviour on mac osx)? Or is it that you would like to overwrite the default behaviour?

You may want to have a click on the field each time a card is open to make sure this works straightaway (i.e., to have the textfield become active so that any scroll comes to act on it). For this use the click instruction (on opencard - click at "100,100" - end opencard) or the mouseup instruction (on opencard - send mouseup to field "scrollablefield" - end opencard).

Don't hesitate to let us know ways in which this answer fails to answer your question.

JonathanLynch
Posts: 22
Joined: Mon Apr 10, 2006 1:42 pm
Location: Atlanta
Contact:

Post by JonathanLynch » Mon Apr 10, 2006 7:24 pm

If you want to scroll a group (background), you need to intercept the rawkeydown message.

Here is the relevant script for a windows system, I assume it works on other systems as well:

on rawkeydown pKey
if pKey = 65309 then
put the vscroll of me into A
put A - 14 into B
set the vscroll of me to B
else if pKey = 65308 then
put the vscroll of me into A
put A + 14 into B
set the vscroll me to B
else
pass rawkeydown
end if
end rawkeydown

blingbling
Posts: 11
Joined: Mon Apr 10, 2006 5:39 pm

Post by blingbling » Mon Apr 10, 2006 7:45 pm

Hi Jonathan and Marielle,

I know you guys from the list! You've always been very supportive. It's nice to see friendly faces, so to speak. :D :D

Jeez, maybe I shoulda just used my name for my username instead of some silly alias. I want to be personable. What do you suggest?

Jonathan -- I'm amazed! Your script for scrolling the bg worked perfectly, right out of the box. It usually isn't that easy. Thanks a bunch and a half.

Marielle -- I didn't know that was default behavior! :oops:

I know what to do about the backgrounds now, but I'm still stumped about the fields. The fields I want to scroll with the wheel are locked and list behavior is turned on, so I can't click on them first, as far as I know. If I do, the field script will just direct me to the location referenced by the clickable line.

I'd also like to be able to avoid the extra mouseclick, if possible. I.e., I'd like to designate a given field on a given card as mouse-wheel-able one.

If I may get really picayune, I'd like the designated mouse-wheel-able field on a card to remain the mouse-wheel-able field regardless of where else I click on the card, before I try to scroll the field.

Is this possible? If so, a brief suggestion or two will probably be sufficient.

Thanks again,


Tim

blingbling
Posts: 11
Joined: Mon Apr 10, 2006 5:39 pm

Post by blingbling » Mon Apr 10, 2006 7:54 pm

It's me again. Oopsie! I figured it out, immediately after inquiring. I shoulda thought about it first more. :oops:

I tried modifiying Jonathan's script thus:

on rawkeydown pKey
if pKey = 65309 then
put the vscroll of BG field "index field" into A
put A - 14 into B
set the vscroll of BG field "index field" to B
else if pKey = 65308 then
put the vscroll of BG field "index field" into A
put A + 14 into B
set the vscroll BG field "index field" to B
else
pass rawkeydown
end if
end rawkeydown

I put it into the script of the card the field resides on. It works great! Question answered. And, in addition, I now have some idea about how to use "on rawkeydown" :)

Cheers,


Tim

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Mon Apr 10, 2006 9:23 pm

blingbling wrote:It's me again. Oopsie! I figured it out, immediately after inquiring. I shoulda thought about it first more. :oops:
<snip> It works great! Question answered. And, in addition, I now have some idea about how to use "on rawkeydown" :)
Hi Tim,

Glad it worked just fine! Jonathan's script was clearly closer to your needs. Funny how sometimes the fact to write the question help you find the answer :wink:

blingbling
Posts: 11
Joined: Mon Apr 10, 2006 5:39 pm

Post by blingbling » Mon Apr 10, 2006 11:57 pm

Both of these scripts seemed to work intermittently.

I eventually realized that no rawkeydown message get sent by the mouse wheel unless the mouse is "within" something -- within the rect of a button or a field. I.e., if there's a mouseEnter message, not followed by a mouseLeave message, the IDE gets a rawkeydown message from the mouse wheel. Otherwise, it doesn't. It doesn't seem to matter whether the mouse is within a cd btn or field, or a bg btn or field.

The mouse remains within the background, and within the rect of the card or stack, but I guess that doesn't count.

I doubt there's any way to get the mouse wheel to scroll the field or background whether or not the mouse is within the rect of a field or button, but I thought I'd ask. Are there any clever tricks available for this situation?

It is inconvenient at times, if I have to "chase" a field or button, keeping the cursor over it, as it scrolls up and down, to keep the mouse wheel working. But it isn't a tragedy.

Cheers,

Tim

JonathanLynch
Posts: 22
Joined: Mon Apr 10, 2006 1:42 pm
Location: Atlanta
Contact:

Post by JonathanLynch » Tue Apr 11, 2006 12:31 pm

The mousewheel should send a rawkeydown message whenever it is used.

If you put the script in the stack script, does it not work?

JonathanLynch
Posts: 22
Joined: Mon Apr 10, 2006 1:42 pm
Location: Atlanta
Contact:

Post by JonathanLynch » Tue Apr 11, 2006 12:38 pm

Wait, I see the problem now...

What I do is have an image that is transparent, but still receives mouse messages. (one of the ink settings does this, i forget which one off the top of my head)

This image needs to rest at the bottom layer inside the group. I will try to throw something together for you, and send it to you as an example.

JonathanLynch
Posts: 22
Joined: Mon Apr 10, 2006 1:42 pm
Location: Atlanta
Contact:

Post by JonathanLynch » Tue Apr 11, 2006 12:44 pm

OK, I made a sample stack for you.

Your profile doesn't have your Email address. Can you tell me your Email address so I can send the sample stack to you.

BTW, the ink setting for the transparent image that you need to use is noop.

blingbling
Posts: 11
Joined: Mon Apr 10, 2006 5:39 pm

Post by blingbling » Tue Apr 11, 2006 4:06 pm

That's very good of you, Jonathan.

I think I can put a transparent image at the bottom layer without too much trouble. It seems like that would work just fine. I hadn't thought of that.

For that matter, a field at the bottom layer would probably do the trick also, I suppose.

Thanks a bunch,


Tim

trevix
Posts: 971
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

mousewheel scrolling, slow update with rawkeydown

Post by trevix » Wed Sep 12, 2007 11:28 am

JonathanLynch wrote:If you want to scroll a group (background), you need to intercept the rawkeydown message.

Here is the relevant script for a windows system, I assume it works on other systems as well:

on rawkeydown pKey
if pKey = 65309 then
put the vscroll of me into A
put A - 14 into B
set the vscroll of me to B
else if pKey = 65308 then
put the vscroll of me into A
put A + 14 into B
set the vscroll me to B
else
pass rawkeydown
end if
end rawkeydown
I've noticed that only part of the rawkeydown messages get caught. This makes for a strange scrolling behaviour: the faster you use the whell, the slower the scroll. I guess because on fast wheeling lots of messages get lost.
Is there any way to change this ? I've tried with "wait" messages and with "flush", with no result.
Where do they go all those lost rawkeydown ?
If I could get those, I could eventually make a nice exponential scroll...

Thanks
Trevix

Post Reply

Return to “Talking LiveCode”