Answer function
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
Well, yes.
The answer dialog is launched on mouseUp, so the mouseDown message passes along the message path until it finds a handler that traps it.
In your case, since you've got the data stack in the message path, it'll get the message before the answer dialog is invoked.
Then when the mouseUp message comes along, the answer dialog appears.
The answer dialog is launched on mouseUp, so the mouseDown message passes along the message path until it finds a handler that traps it.
In your case, since you've got the data stack in the message path, it'll get the message before the answer dialog is invoked.
Then when the mouseUp message comes along, the answer dialog appears.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Answer function
No, I've got a button that triggers the answer dialog on mouseUp, and I've trapped the mouseDown in it, so no mouseDown is sent. The answer dialog appears, and if either button is pressed, the mouseDown handler in the data stack is triggered, with the target shown as 'Button Yes' or 'Button No', so the mouseDown is definitely coming from the answer buttons.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
This raises a question: should we add mouseDown stubs to the answer and ask dialogs to prevent this in the future?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
odysseus- in your mouseDown handler in the data stack, insert a breakpoint as the first line in the handler.
See if the breakpoint is hit *before* the answer dialog comes up.
[update] I just reread the previous two comments.
Yeah, I think the mouseDown message is being passed on by the answer modal dialog.
That just seems wrong.
See if the breakpoint is hit *before* the answer dialog comes up.
[update] I just reread the previous two comments.
Yeah, I think the mouseDown message is being passed on by the answer modal dialog.
That just seems wrong.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Answer function
I think it would be more correct to say that the mouseDown message is generated by the buttons in the answer dialog. The fact that they don’t generate a mouseUp says to me that it’s unintentional (dare I say a bug).
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
Yes - that's what I meant to say. IMO modal dialogs shouldn't generate side effects.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Answer function
I don't understand.I think it would be more correct to say that the mouseDown message is generated by the buttons in the answer dialog. The fact that they don’t generate a mouseUp says to me that it’s unintentional (dare I say a bug).
If I have this in a button:
Code: Select all
on mouseUp
breakpoint
end mouseUp
on mouseDown
answer "Down" with "OK, down"
end mouseDown
craig
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
Craig-
Put a mouseDown handler in a stack script.
on mouseDown
breakpoint
end mouseDown
In a *separate* stack, put a button with the script
on mouseUp
start using stack "" -- the name of the first stack
answer "what?" with "dunno" and "whatever"
end mouseUp
Now click the button.
The answer dialog will appear, but clicking either of the two buttons on it will trigger the breakpoint because the modal dialog is leaking the mouseDown message.
Put a mouseDown handler in a stack script.
on mouseDown
breakpoint
end mouseDown
In a *separate* stack, put a button with the script
on mouseUp
start using stack "" -- the name of the first stack
answer "what?" with "dunno" and "whatever"
end mouseUp
Now click the button.
The answer dialog will appear, but clicking either of the two buttons on it will trigger the breakpoint because the modal dialog is leaking the mouseDown message.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Answer function
Just to clarify, In my button I put:
on mouseUp
answer “Hello” with “Yes” or “No”
end mouseUp
on mouseDown
—do nothing
end mouseDown
So the mouseDown is trapped and not sent
In my data stack I put:
on mouseDown
put target
end mouseDown
Now when I click the button the answer dialog appears, and if I click “Yes”, the command window shows:
button “Yes” (or button “No” if “No” is clicked)
So as there is no other source of mouseDown, it must be generated by the answer dialog buttons . QED
on mouseUp
answer “Hello” with “Yes” or “No”
end mouseUp
on mouseDown
—do nothing
end mouseDown
So the mouseDown is trapped and not sent
In my data stack I put:
on mouseDown
put target
end mouseDown
Now when I click the button the answer dialog appears, and if I click “Yes”, the command window shows:
button “Yes” (or button “No” if “No” is clicked)
So as there is no other source of mouseDown, it must be generated by the answer dialog buttons . QED
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
...and there's a simple fix for this. You wanna file the bug report or should I?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Answer function
Hi Odysseus,
I could not replicate your problem (LiveCode Indy 9.6.1)
Just in case i've misunderstood your issue, the problem you describe is:
- Main stack has a mouseDown event, in this example puts the name of target
- Modal stack has other buttons - when they clicked they trigger the mouseDown even in the main stack, or if an answer dialog is shown, clicking on the buttons of the answer dialog triggers the mouseDown event in the main stack.
Here is a test project where the main stack has a mouseDown handler that puts the name of target.
Opening a substack as modal, there are two buttons, one with a mouseUp handler that answers "hello" with "yes" or "no", and one that does nothing.
No matter what button i click, the only time anything is put into the message box is when i click on the button in the main stack that opens the modal stack.
If I've understood correctly, this is the opposite of what you're observing?
If you are observing something else, or if your problem is a different one, perhaps share a simplified stack showing the issue?
I could not replicate your problem (LiveCode Indy 9.6.1)
Just in case i've misunderstood your issue, the problem you describe is:
- Main stack has a mouseDown event, in this example puts the name of target
- Modal stack has other buttons - when they clicked they trigger the mouseDown even in the main stack, or if an answer dialog is shown, clicking on the buttons of the answer dialog triggers the mouseDown event in the main stack.
Here is a test project where the main stack has a mouseDown handler that puts the name of target.
Opening a substack as modal, there are two buttons, one with a mouseUp handler that answers "hello" with "yes" or "no", and one that does nothing.
No matter what button i click, the only time anything is put into the message box is when i click on the button in the main stack that opens the modal stack.
If I've understood correctly, this is the opposite of what you're observing?
If you are observing something else, or if your problem is a different one, perhaps share a simplified stack showing the issue?
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
It's not the mainstack, it's a library. The global scope of the library allows it to catch any events but trapped elsewhere.
The more I think about it, the more it seems impractical for all IDE components and all third-party plugins to trap all possible messages just for edge cases like this. It's very rare to handle system messages in a library.
The more I think about it, the more it seems impractical for all IDE components and all third-party plugins to trap all possible messages just for edge cases like this. It's very rare to handle system messages in a library.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Answer function
Sorry Richard, i kinda skimmed most of this and just really paid attention to Odysseus' post, where there is no mention of libraries...
Thought i'd try to replicate the reported error but i couldn't... but that is only based on his example in this post.
Thought i'd try to replicate the reported error but i couldn't... but that is only based on his example in this post.
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
Richard- while I do somewhat agree with
I don't think it's right that a modal dialog should leak a mouseDown message. It's a simple fix to the Answer dialog stack... it's already obviously got a mouseUp handler, so an empty mouseDown handler to match it neatly solves the problem. While this may well be considered an edge case, it's taken us three pages of comments here to figure out what's going on. AFAIK Answer dialogs will otherwise only respond to mouseUp messages.it seems impractical for all IDE components
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
If you feel limiting this to the ask and answer dialogs would be sufficient, that would be easy to remedy.
I can imagine many other unexpected anomalies with libraries that handle system messages, though, so I'm not sure those would be enough.
In the other hand, I've read nearly every post here and in the mailing list since their respective beginnings, and I've not seen this come up before.
LiveCode is very flexible. Handling messages globally comes with a certain responsibility. It's rare that folks do that at all, and rarer when done by those unfamiliar with the implications of that choice.
All that said, I see good arguments for both doing the work and for just adding a caveat in the docs. As long as I'm not doing the work I'll happily go along with whomever does.
I can imagine many other unexpected anomalies with libraries that handle system messages, though, so I'm not sure those would be enough.
In the other hand, I've read nearly every post here and in the mailing list since their respective beginnings, and I've not seen this come up before.
LiveCode is very flexible. Handling messages globally comes with a certain responsibility. It's rare that folks do that at all, and rarer when done by those unfamiliar with the implications of that choice.
All that said, I see good arguments for both doing the work and for just adding a caveat in the docs. As long as I'm not doing the work I'll happily go along with whomever does.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn