X's cool mouse tricks

MisterX b.xavier at internet.lu
Sun Feb 12 07:20:25 EST 2006


hi everyone, 

since the list was a little dry lately, I thought I'd throw some juice to
the xtalk!

The trick is about the scrollbardrag event which doesn't work the same way
in scrollable groups as it does in scrollable fields when you use your
mouse's scrollwheel... 

This trick enables mouse scrollwheels to work in any scrollable groups (and
more - see the suggestions later)!

It's fixed for vertical scrolling but you can change it to go diagonal if
you want -- im sure you'll find how to do that soon ;)

This trick is for groups with vertical scrollbars that scroll a number of
items into view as you scroll. I use them for grids larger than the stack
size (in xosmedialib for example where you see 8 or more out of 100's of
lines of images in a grid) or in tab panels where the panel is too short to
show all the controls available for a panel of settings. 

The group has preferably the property loclocation = true or it may resize
itself automatically.

Its Vertical scrollbar is visible.

The script goes into the script of the group that you want to scroll...

The group script is the following

constant Cscrollvalue = 48 
-- change this to scroll faster or slower...

on rawkeydown w
  
  put the height of me into s1
  put the vscroll of me into s
  
  if w is 65309 then
    if s <= Cscrollvalue then 
      set the scroll of me to 0
    else 
      set the scroll of me to s - Cscrollvalue
    end if
  else if w is 65308 then
    if s + Cscrollvalue >= s1 then 
      set the scroll of me to s1
    else 
      set the scroll of me to s + Cscrollvalue
    end if
  end if
  pass rawkeydown
end rawkeydown

scrollable fields in the group interfering? Haven't seen it yet but please
report it if you find a problem.

Note: since group's opaqueness doesn't work in XP or OSX, you may have to
lay a bg field or graphic in background of the group carpeting all the
group's objects to catch the event - in win xp the mouse-scroll is cauth
only if you hover a control in this scrolling group - if the mouse is within
the rect of the group but on top of a tab menu behind the (non-opaque opaque
) group for example it wont trigger. Solution to this problem without the
need of a bg-carpet object welcome - see bugzilla 3314.

Not tested on Macs... all issues and corrections welcome!

bugzilla 3313 and 3314 already where innevitable trying to make this
simpler...

Other possible uses: (untested)

- Using the scrollwheel to change tabs
- Using the number fields and or (+/-) controls
- navigating cards or windows or controls (in the winNO2, NavNO2, NavH20,
propsNO2 stacks soon)
- using the mousewheel to change the focus...

Harder if not impossible:
- use the scrollwheel to choose items from a menu or option menu list items.

cheers
Xavier
http://monsieurx.com/taoo




More information about the use-livecode mailing list