Detect Horizontal Scrolling in DataGrid

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Wed Apr 08, 2009 11:54 pm

Detect Horizontal Scrolling in DataGrid

Post by dickey » Mon Aug 22, 2011 1:07 am

Hello All,

I have a group containing fields I use to filter a DataGrid object and wish to scroll them simultaneously when a user scrolls horizontally in the DataGrid.

So within the script of the DataGrid I wished to intercept the horizontal scrolling event, then similarly scroll the filter field group before passing the horizontal scroll event in the DataGrid.

I figured in the script of the DataGrid something like:

Code: Select all

setprop dgHScroll [pValue]
   set the hScroll of group "grpFilter" to pValue
   pass dgHScroll
end dgHScroll
, but that isn't it.

I can manually do it from a button using:

Code: Select all

  get the dgHScroll of group "DataGrid 1"
  put it into tHScroll
  set the hScroll of group "grpFilter" to tHScroll
, which proves the concept - however I need intercept the event when it happens.

Any assistance greatly appreciated.

Kind regards, Andrew

Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

Re: Detect Horizontal Scrolling in DataGrid

Post by Steve Denney » Tue Aug 23, 2011 1:39 am

Hi Andrew,
Not quite sure what you're after, but i'm thinking it's something like this:

Code: Select all

on scrollBarDrag pValue
   set the hScroll of group "grpFilter" to pValue
end scrollBarDrag
Look up scrollBarDrag in the dictionary. It gets sent to flds, grps, sbs when they're scrolled. You might need a pass scrollBarDrag with the above if you want the scrolled fld/grp (the one that sends the message) to scroll--not sure about that.

scrollBarDrag newPos

...is a message sent by the scrolled object so you can use it to do whatever you want i.e.

Code: Select all

on scrollBarDrag newPos
   doStuff newPos
end scrollBarDrag
where doStuff is a function or procedure defined higher up the message path.
Steve

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Wed Apr 08, 2009 11:54 pm

Re: Detect Horizontal Scrolling in DataGrid

Post by dickey » Tue Aug 23, 2011 2:30 am

Hello all,

A solution provided by Zryip The Slug via the LiveCode Developer List:

To intercept horizontal scrolling in the DataGrid and to similarly scroll another group, in the script of the DataGrid add the following handler:

Code: Select all

on dgScrollbarDragH pScrollValue
  set the hScroll of group "grpFilter" to pScrollValue
  pass dgScrollBarDragH
end dgScrollBarDragH
I hope that assists someone else.

Kind regards, Andrew

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Wed Apr 08, 2009 11:54 pm

Re: Detect Horizontal Scrolling in DataGrid

Post by dickey » Tue Aug 23, 2011 2:37 am

Thanks Steve,

I did try that, however it seems the DataGrid has it's own custom properties in respect of scrollbars.

Zryip corrected my earlier attempt at coding against the datagrid's custom properties.

Thanks again for posting. Steve.

Kind regards, Andrew

Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

Re: Detect Horizontal Scrolling in DataGrid

Post by Steve Denney » Tue Aug 23, 2011 4:54 am

Apologies Andrew, I didn't know what a datagrid was (just looked it up). In fact I've fairly recently made a database app from scratch with similarly scroll-able, user-resizeable column flds--sheesh, I wish I'd known. (At least I can set the scrollwidths).
Steve

Post Reply