Cannot wait for the mouseClick

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Cannot wait for the mouseClick

Post by dunbarx » Thu Aug 19, 2021 2:58 pm

I thought I knew how things worked. From a handler in a button, I want to click on a line in a field and get the line clicked on. Real tough stuff.

Code: Select all

on mouseup
   set the cursor to cross
   wait until the the mouseClick with messages --NOPE
   wait until the the mouse is down with messages --WORKS
   put word 2 of the mouseLine into tLine
Why doesn't the mouseClick work? Something to do with the timing of events, because trying to return "the clickLine" also will not do, even using "the mouse is down" method.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Cannot wait for the mouseClick

Post by jacque » Thu Aug 19, 2021 4:49 pm

This was changed way back in the MC days. Mouse clicks require tracking paired system events and LC doesn't do that. Checking mouseDown requires only one check and presumably the mouse is down long enough for the internal loop to catch it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Cannot wait for the mouseClick

Post by andresdt » Thu Aug 19, 2021 5:39 pm

Hi
Maybe this can help you

viewtopic.php?f=9&t=35684#p204074

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Cannot wait for the mouseClick

Post by stam » Thu Aug 19, 2021 5:57 pm

Hi Craig - you're obviously a lot more experienced but i'm not sure i understand what you're after.

It's weird reading the code as mouseClick must be dependent on both mouseDown and mouseUp, LC probably sees your code a bit like this ;)
your code ;).jpg

Joking aside, I suspect that it's something to do with how fields handle mouse events when they are editable - i cannot get this to work when the field is editable, but if i lock the text of the field, this does work:

Code: Select all

on mouseDown
    local tLine
    put the text of the clickLine into tLine
    put word 4 of tLine
    pass mouseDown
end mouseDown
When the text is not locked neither mouseDown or mouseUp seem to respond... would be good to know if there's a way around that?
I'm guessing this may require some with the selection of text instead of mouse events in unlocked fields...
Stam

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

Re: Cannot wait for the mouseClick

Post by dunbarx » Thu Aug 19, 2021 6:22 pm

Stam.

Good point about a locked field have entirely different "properties" than unlocked, but it is indeed a locked field I am querying. And I intended that the mouse be up to invoke the function. The dictionary for "the mouseClick" simply talks about the user "clicking", without saying exactly what that really means

Interestingly, if I triple-click using the "mouseClick" version, it works. It does not matter if I have a "mouseEnter" handler in the field tha, sets focus on that field.

As Jacques explains, it is just how LC works. I used such a gadget in HC, but that is a different world, despite the fact that I rarely separate the two at a basic level.

Craig

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Cannot wait for the mouseClick

Post by stam » Thu Aug 19, 2021 11:59 pm

Hi Craig,
Still not sure why you'd want to use the mouseClick, even if you want to this to trigger on mouseUp.

Personally when i've done this type of thing, i have script variable that keeps track of the clickLine and stores it on mouseDown; then fire off an action with this in the mouseUp handler (usually checking the mouseLoc).

Would that not be more predictable?
Stam

Post Reply

Return to “Talking LiveCode”