Script of Datagrid Group triggered by Click in Scrollbar

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
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Script of Datagrid Group triggered by Click in Scrollbar

Post by montymay » Sat Feb 25, 2017 9:31 am

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

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: Script of Datagrid Group triggered by Click in Scrollbar

Post by Ledigimate » Sat Feb 25, 2017 7:29 pm

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
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Script of Datagrid Group triggered by Click in Scrollbar

Post by montymay » Mon Feb 27, 2017 11:18 am

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

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: Script of Datagrid Group triggered by Click in Scrollbar

Post by Ledigimate » Mon Feb 27, 2017 12:58 pm

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
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”