Page 1 of 1

Script of Datagrid Group triggered by Click in Scrollbar

Posted: Sat Feb 25, 2017 9:31 am
by montymay
Hello

I'm getting to know datagrid tables for the first time and have encountered a problem: when I click on the vertical or horizontal scrollbar to go up or down, or left or right, the script for the datagrid group is triggered. Clicking a line of my table successfully takes me to the intended card, populated by the correct data, but clicking on the scrollbars likewise opens the same card with the same data. Could it be a scripting error or the design of my rows? Thanks for any comments.

Monty

Re: Script of Datagrid Group triggered by Click in Scrollbar

Posted: Sat Feb 25, 2017 7:29 pm
by Ledigimate
Hi Monty,

You can use the following code to mask out the datagrid scrollbars:

Code: Select all

on mouseUp pButton
   local hScrollClicked, vScrollClicked
   if pButton  is 1 then
      put the clickLoc into tLoc
      put (the dgProps["show hscrollbar"] of me) and within(scrollbar 1 of me, tLoc) into hScrollClicked
      put (the dgProps["show vscrollbar"] of me) and within(scrollbar 2 of me, tLoc) into vScrollClicked
      if not (hScrollClicked or vScrollClicked) then

         answer "hey presto"

      end if
   end if
end mouseUp
I hope this helps

- Gerrie

Re: Script of Datagrid Group triggered by Click in Scrollbar

Posted: Mon Feb 27, 2017 11:18 am
by montymay
Hello Gerrie,

Your script did not work for me, but it gave me an idea that seems to work so far, but maybe it will have unforeseen consequences.

Here's my modification:

Code: Select all

       put the clickLoc into tLoc
       --put (the dgProp["show hscrollbar"] of me) and within(scrollbar 1 of me, tLoc) into hScrollClicked
       --put (the dgProp["show vscrollbar"] of me) and within(scrollbar 2 of me, tLoc) into vScrollClicked
       put within(scrollbar 2 of me, tLoc) into vScrollClicked
       put within(scrollbar 1 of me, tLoc) into hScrollClicked
       if vScrollClicked or hScrollClicked then
         exit mouseup
         else
etc.
Please let me know if you see an error. BTW, the need for this workaround seems like a bug, but it must be idiosyncratic to my environment or others would have reported it.

Monty

Re: Script of Datagrid Group triggered by Click in Scrollbar

Posted: Mon Feb 27, 2017 12:58 pm
by Ledigimate
That's great :D

The part you've commented out also takes the visibility of the datagrid's scrollbars into account, because if not then it would behave as if they were visible even when they're not.
To see what I mean you need to play with the datagrid's "Show hScrollbar" or "Show vScollbar" properties a bit and observe the result.

Gerrie