Answer function

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

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

Re: Answer function

Post by dunbarx » Thu Nov 12, 2020 7:28 pm

If the OP was, as Mark wondered, using his own custom "answer" dialog, then all bets are off. No mystery, apart from whatever went awry.

But I will bet a dime that the ordinary dialog was used, but that the problem came a bit afterwards. This requires looking at the handlers.

Craig

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 8:04 pm

I have a stack separate from the main stack but I associate it by ‘start using’ on startup. It contains configuration data and drawings which are displayed as an overlay palette on the main stack. This data stack has a mouseUp script so that users can click on the drawings to perform certain actions, the mouseUp sends commands to the card behind it in the main stack.

As I had closed the data stack I was not expecting it to take any further part in proceedings, but it appears the ‘answer’ buttons were sending a mouseUp to the closed stack, which was then sending its message to the main stack and confusing it. I am using ‘answer’ as is, nothing fancy.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8322
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Answer function

Post by FourthWorld » Thu Nov 12, 2020 8:27 pm

odysseus wrote:
Thu Nov 12, 2020 8:04 pm
I have a stack separate from the main stack but I associate it by ‘start using’ on startup.
Which system messages are handled in that library?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3202
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Answer function

Post by mwieder » Thu Nov 12, 2020 9:34 pm

"start using" a stack won't mess up the message path for mouseUp messages that way.
Using the data stack script as a frontscript will.
Check to make sure you haven't inserted the stack script as a frontscript.

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 10:16 pm

I haven’t even investigated frontscripts yet. The data stack seems to have a life of its own whether its open or not.

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

Re: Answer function

Post by dunbarx » Thu Nov 12, 2020 10:32 pm

but it appears the ‘answer’ buttons were sending a mouseUp to the closed stack,
Nope. Not unless you tell it to, and that would have to be explicitly done after the answer dialog has closed, with the selection from the dialog button having been placed automatically into the local variable "it".

What did you do on the lines immediately following the "answer" command line?

Craig

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 11:59 pm

Sorry to contradict you, but I know what I found. In the script with the the ‘answer’ command, I placed a ‘put it’ directly after the answer command, but it locked up without showing ‘it’, so I know it never got there. Then I found that if I disabled the mouseUp message from the ‘data’ stack, i.e. stopped it sending the command to the main stack, but putting a ‘put “mouseUp received” ‘ line in the script, I saw this was triggered by the buttons in the answer box. Without the spurious transferred message to the main stack, the system no longer locked up.

The cure was then simple, I just blocked onward messages from the data stack if the trigger target was a button, as I never use buttons in the data stack cards.

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

Re: Answer function

Post by dunbarx » Fri Nov 13, 2020 12:45 am

I have been contradicted so often (usually with good reason) that no apologies are necessary.

When you "put it" into the line immediately following the answer command line, were you stepping through the code at the time? I have been interested, when stepping through, which line crashed LC.

This is all detective work, and I will bet another dime that when we find the culprit, everyone will say, "of course". You too. :wink:
I saw this was triggered by the buttons in the answer box.
Now then, I have no idea what this could be, or why you think a "mouseUp" message could be sent that way.

What is this?
but putting a ‘put “mouseUp received” ‘ line in the script, I saw this was triggered by the buttons in the answer boxI
And what did you write, in-line? The actual string "put “mouseUp received"? If you did, what was the condition that made that fire? The reason I ask is that, on its own, LC would put the string “mouseUp received" into the message box.

If you can, this may all be easier if you can post some of the pertinent code.

Craig

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Fri Nov 13, 2020 12:57 am

I don’t think any further detective work is required. If an answer box is displayed, then when either button is pressed, it sends a mouseUp message which filters through to a ‘closed’ stack. If that stack contains a mouseUp handler, then the code in that handler will be actioned. No mystery, that’s just what happens.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3202
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Answer function

Post by mwieder » Fri Nov 13, 2020 2:09 am

It isn't, actually.
But if you've got something that's working for you, great. Let's move on.

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Fri Nov 13, 2020 11:09 am

It is - actually. A ‘put the target’ message I put into the mouseUp handler in the closed stack to intercept it shows that the target was button “Yes” if that was pressed, or button “No” if that was pressed, so that shows conclusively it was coming from the Answer box.

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

Re: Answer function

Post by dunbarx » Fri Nov 13, 2020 3:39 pm

I cannot tell if we are off in the weeds or not.

On a new card with a button, and this in the button script:

Code: Select all

on mouseUp
   answer "X" with "Y" or "Z"
end mouseUp

--on mouseDown
 --  answer "A" with "B" or "C"
--end mouseDown
This is what is shown in the message watcher, with "mouseEnter", "mouseLeave" and "mouseMove" suppressed:
messages.zip
(26.23 KiB) Downloaded 20 times
The "mouseDown" and "mouseUp" messages are sent before the dialog is rendered. No messages at all are sent when a dialog button is selected, and of course the dialog is automatically dismissed.

If I uncomment the "mouseDown" handler, leaving both "active", the message watcher shows:
messages2.zip
(19.13 KiB) Downloaded 19 times
"MouseUp" never even fires.

All this was to prove to me that an answer dialog does ONE thing well. It places the text of the selected button into the local variable "it", and then conveniently disappears. My confusion in all this entire discussion centers around a "mouseUp" message purportedly being sent down the message path, from the dialog, based on the button clicked on.

I don't get it.

Craig

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

Re: Answer function

Post by dunbarx » Fri Nov 13, 2020 3:45 pm

Just to make sure, because I often do not know what I am talking about, I placed a "mouseUp" handler in the card script, to see if any such message snuck through after clicking the answer dialog button. I assumed that this would be the best place to trap any such varmint.

Nothing.

Of course.

@Odysseus. We are all obviously misunderstanding what you are doing. I have no doubt you are seeing what you are seeing. But I have no idea what you are seeing.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8322
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Answer function

Post by FourthWorld » Fri Nov 13, 2020 4:43 pm

odysseus wrote:
Fri Nov 13, 2020 11:09 am
It is - actually. A ‘put the target’ message I put into the mouseUp handler in the closed stack to intercept it shows that the target was button “Yes” if that was pressed, or button “No” if that was pressed, so that shows conclusively it was coming from the Answer box.
No doubt. But the question is how? The answer dialog mouseup message isn't passed.

Mark's question about frontscripts seems relevant.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

odysseus
Posts: 41
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Fri Nov 13, 2020 5:07 pm

My bad - everything I posted was correct EXCEPT its mouseDown that does it not mouseUp, sorry.

Just to double check it wasn't any of my code,I set up a new system with two stacks, stack 1 includes 'start using' stack 2. Stack 2 has a mouseDown handler which just says 'put the target'. That captures the answer buttons triggered from stack 1. It all doesn't matter now I know, but it might catch someone out in the future - who knows?

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”