MenuHistory bug?

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: 10339
Joined: Wed May 06, 2009 2:28 pm

MenuHistory bug?

Post by dunbarx » Wed Jan 18, 2023 10:15 pm

Took me a LONG time to find out why my code was not working.

When you set the menuHistory of an Option Menu button, a "menuPick" message is supposed to be sent to that button. But is is sent only if there is a change in the current menuHistory. In other words, if the menuHistory is already 3, setting that property to 3 will not send the message.

Feature? Bug? Something that everyone knows about?

Craig

stam
Posts: 3092
Joined: Sun Jun 04, 2006 9:39 pm

Re: MenuHistory bug?

Post by stam » Thu Jan 19, 2023 8:22 pm

Not sure that's a bug...

menuHistory specifies the number of the currently selected item of the menu that belongs to a button.

if it's already set at the desired number, why would a message be sent?

If you really need this to trigger, why not set menuHistory to empty first, then set it to the desired number? That should then always trigger...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: MenuHistory bug?

Post by dunbarx » Thu Jan 19, 2023 10:56 pm

Stam.

I had no problem working around this, the very way you suggested. I was just wondering if it made any sense for LC NOT to send the message, however pointless it would be to set the menu to the very state it was already in. I mean, why bother to not send it? It assume it would make the engine just a tiny bit simpler. Could there be any actual reason?

Not an earth-shaking issue...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: MenuHistory bug?

Post by FourthWorld » Fri Jan 20, 2023 8:30 am

I had a conversation with Dr Raney about this back in the day. He reminded me that while pulldown menus are command inputs, option controls are selelectors. As such, he felt that any script triggered by a change in the selected item of an option control would only be redundant when there is no change.
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: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: MenuHistory bug?

Post by dunbarx » Fri Jan 20, 2023 3:19 pm

Richard.

Nope. Don't get that at all. Say I have an option menu with these menu items:
A
B
C
D
with, say, "B" currently selected and displayed. In the button script:

Code: Select all

on menuPick pItemName
   beep 2
   put pItemname into fld 1
end menuPick
I just like to hear two beeps. It comforts me.

But if I select "B" because I just want to, I get no beeps. I am not certain I even invoked the menu properly, perhaps accidentally clicking badly or off screen. The message was not sent, because "B" was already selected. No comfort at all.

Wrong. :shock:

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: MenuHistory bug?

Post by dunbarx » Fri Jan 20, 2023 3:22 pm

In other words, what possible advantage is there in not sending the message? Why not just let the normal process, er, proceed, regardless of whether or not anything changes inside the menu button? This actually threw me for a while in an app I was working on. I thought I had locked messages. I thought LC had frozen. I thought...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: MenuHistory bug?

Post by FourthWorld » Fri Jan 20, 2023 8:08 pm

dunbarx wrote:
Fri Jan 20, 2023 3:22 pm
In other words, what possible advantage is there in not sending the message? Why not just let the normal process, er, proceed, regardless of whether or not anything changes inside the menu button?
I suppose it depends on how one defines "normal". Can you help me find examples where user interactions with other controls which don't change an option control label result in the option control providing feedback that no change occurred?

I may be overlooking a common scenario, but TBH I can't recall seeing that, and offhand I'm struggling to come up with a use case where I'd want to inform the user that nothing changed. But software design is a vast universe, so I'm eager to learn about cases where that can be useful.

All I know is that the docs describe menuHistory as only being sent when the value changes, much as closeField is only sent when the text of a field changes.

And similar to how exitField provides an alternate message to indicate leaving a field where text has had no change, in the less common case where you'd want to provide notification of no change occurring LC still provides a way to do that, by explicitly sending the message from the script of the control where the menuhistory is set.
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: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: MenuHistory bug?

Post by dunbarx » Fri Jan 20, 2023 9:28 pm

Richard.

Certainly I could:

Code: Select all

send "menuPick B" to btn myOption
And I appreciate and use the field "close" and "exit" options.

I suppose, apart from sheer pedantry (which you know from long experience with me I suffer from) I was just miffed that I spent time trying to figure out why a certain process was intermittently failing. This involved working with a number of option menus, and I kept getting hung up. It took a little while to realize that the hang occurred when there was no change to the particular option menu I accessed.

Thanks for all your help.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: MenuHistory bug?

Post by FourthWorld » Fri Jan 20, 2023 9:52 pm

dunbarx wrote:
Fri Jan 20, 2023 9:28 pm
...I was just miffed that I spent time trying to figure out why a certain process was intermittently failing.
You just described much of my life. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply