MouseDown script on Datagrid never reached [RESOLVED]

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

MouseDown script on Datagrid never reached [RESOLVED]

Post by synto » Tue Aug 13, 2019 3:28 pm

Hi all,

I have to trap the mousedown event on a datagrid to get the mouse coords.
I have read the LC lesson about the mouseDown on datagrid, but unfortunatly, the mouseDown script is never executed. (Verified with a breakpoint that is never reached)
I also tried this following script in the Behavior Script of the datagrid, but it is never executed too.

Code: Select all

local sMouseDistX, sMouseDistY
on mouseDown pMouseBtnNum	
   put item 1 of the mouseLoc into sMouseDistX
   put item 2 of the mouseLoc into sMouseDistY
end mouseDown
After 2h of test & misunderstood, i can't explain why... perhaps someone here known the problem ?
Last edited by synto on Tue Aug 13, 2019 6:21 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseDown script on Datagrid never reached

Post by dunbarx » Tue Aug 13, 2019 4:13 pm

Hi.

Where is the handler? If you place this in the group script:

Code: Select all

on mouseDown	
   answer random(99)
end mouseDown
Does it fire?

Craig

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Re: MouseDown script on Datagrid never reached

Post by synto » Tue Aug 13, 2019 4:38 pm

I have tried to place the handler in Behavior script and in Group Script, none worked
I have to say that the datagrid is in a group to manage scrolling.

Your script does'nt make any popup.

But i can display a popup in the mouseUp handler in Behavior script.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseDown script on Datagrid never reached

Post by dunbarx » Tue Aug 13, 2019 5:49 pm

Have you checked to see if there are any "mouseDown" handlers along the message hierarchy? Do a search for that in "Find and "Replace".

DataGrids are complex, but they still follow the rules. There are just many more places that a handler might get trapped and not passed.

Craig

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Re: MouseDown script on Datagrid never reached

Post by synto » Tue Aug 13, 2019 6:15 pm

Hmmm... strange
In the behavior script, I have a MouseUp and MouseDown handlers.
I use Find and Replace on the stack.
MouseUp isn't found, but is working (answer "up" is display)
MouseDown handlers are found in lot of RowTemplate (it's some empty MouseDown handler)

So i delete MouseDown handler from RowTemplate, and zero MouseDown handler are found now.
The handler MouseDown is executed in my Behavior script (answer "down"), but now the MouseUp does'nt display any popup.

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Re: MouseDown script on Datagrid never reached

Post by synto » Tue Aug 13, 2019 6:21 pm

I remove the answer in MouseDown, probably interfering with mouse event.
And that's ok now !

I discover the find and replace, it is a very good tool to search for handler and other stuff in a stack.

Thank you very much Dunbarx !

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseDown script on Datagrid never reached [RESOLVED]

Post by dunbarx » Tue Aug 13, 2019 7:47 pm

Good.

Know that you can place a message trap anywhere in the hierarchy, and if you also want to trap it again, higher up in that hierarchy, simply "pass" it.

Code: Select all

on mouseDown
    doYourStuff
    pass "mouseDown"
end mouseDown
You can even send a message farther down, or anywhere for that matter. Say this is in the stack script:

Code: Select all

on mouseDown
    doYourStuff
    send "mouseDown" to btn "buttonWayDownOnTheCard"
end mouseDown

Craig

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Re: MouseDown script on Datagrid never reached [RESOLVED]

Post by synto » Wed Aug 14, 2019 7:52 am

Thank you for these explanations Craig, i haven't really used "pass" command yet, but the "send" (and "call") is very usefull. I use it for sending my own message, beetween cards for example, or other stuff.
But never to send "system" message, i'm afraid of breaking the LC hierarchy system message, and have unpredictable behavior.
But now, you say it, i will try.

Thanks for all, have a good day.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseDown script on Datagrid never reached [RESOLVED]

Post by dunbarx » Wed Aug 14, 2019 2:30 pm

Definitely experiment. You will not break anything.

Craig

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”