Page 1 of 1
Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 2:58 pm
by dunbarx
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
Re: Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 4:49 pm
by jacque
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.
Re: Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 5:39 pm
by andresdt
Re: Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 5:57 pm
by stam
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
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
Re: Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 6:22 pm
by dunbarx
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
Re: Cannot wait for the mouseClick
Posted: Thu Aug 19, 2021 11:59 pm
by stam
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