Why Am I Always a Beginner???

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: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Why Am I Always a Beginner???

Post by dunbarx » Mon Mar 09, 2020 11:44 pm

I make any kind of menu-style button. I put something really complex in its script:

Code: Select all

on menuPick pItemName
   put pItemName 
end menuPick

on mouseDown
end mouseDown
Works fine. BUT, if I comment out the "mouseDown" handler, it does not work at all; the menuPick handler does not fire.

I was playing with an long time running stack, and all of a sudden it did not work. I only knew about the mouseDown message because the Message Watcher told me it was sent. I was not surprised at that. I am surprised, however, about the other stuff. I never needed to trap and bury "mouseDown" before.

Passing "mouseDown" in its handler also (no surprise, sort of) disables the menu.

Craig

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

Re: Why Am I Always a Beginner???

Post by FourthWorld » Mon Mar 09, 2020 11:49 pm

I use menuPick all the time, and very rarely with a mouseDown handler in the same script. Can you post a sample stack with this anomaly?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Why Am I Always a Beginner???

Post by dunbarx » Tue Mar 10, 2020 12:38 am

Richard.

Just saw your post as I was making a test on my home computer. Works fine without any "mouseDown" nonsense.

This is not the first time I have found weird things happening to my work Mac. Tomorrow I will restart the machine and see ( I had already quit and reopened LC).

The workaround (trap and bury "mouseUp"), if you can call it that, seems stable. It may be me that is not stable.

Watch this space...

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Why Am I Always a Beginner???

Post by richmond62 » Tue Mar 10, 2020 8:57 am

I'm a beginner after about 19 years of RR/LC and about 44 years trying to program computers
so I don't know why you are asking that question. 8)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Why Am I Always a Beginner???

Post by bogs » Tue Mar 10, 2020 9:56 am

I am a little confused, Craig.... your first post specifically listed this code:
on menuPick pItemName
put pItemName
end menuPick

on mouseDown
end mouseDown

and then specifically said
dunbarx wrote:
Mon Mar 09, 2020 11:44 pm
Works fine. BUT, if I comment out the "mouseDown" handler, it does not work at all; the menuPick handler does not fire.
After Richard's answer you said :
Just saw your post as I was making a test on my home computer. Works fine without any "mouseDown" nonsense...
...
The workaround (trap and bury "mouseUp"), if you can call it that, seems stable. It may be me that is not stable.
Which is it? mouseUp? mouseDown? both? neither?

Aside from that, I would like to know if you have {mouseDown or mouseUp} elsewhere further down the message path in the code. If you do, then that would likely be the reason you need to trap {mouseDown or mouseUp} for that object, as I am pretty sure that {mouseDown or mouseUp} takes precedence over menuPick Image
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Why Am I Always a Beginner???

Post by richmond62 » Tue Mar 10, 2020 11:48 am

menuPrick.png
-
This stack has a mouseDown in both the card and in the drop-down menu.

When you click on the drop-down menu the mouseDown fires first, followed by the menuPick.
Attachments
Menu Prick.livecode.zip
Here's the stack
(34.29 KiB) Downloaded 211 times

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

Re: Why Am I Always a Beginner???

Post by dunbarx » Tue Mar 10, 2020 12:58 pm

The reason I will always be a beginner is because I am lazy.

The stack in question has a mouseDown handler in the card script. That handler tests a custom property, such that if that condition is not met, it exits to top. My poor menuButton had no idea of that. The handler was meant to deal with quite other issues.

That is why I have to head "mouseDown" off at the pass in the button.

Thanks to all for bearing with me, as I learn how LC actually works.

Craig

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Why Am I Always a Beginner???

Post by sritcp » Fri Mar 13, 2020 10:05 pm

zen.png

Post Reply

Return to “Talking LiveCode”