menuPick doesn't fire if menu was dropped via "click at..."

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
MichaelBluejay
Posts: 234
Joined: Thu Jul 01, 2010 11:50 am

menuPick doesn't fire if menu was dropped via "click at..."

Post by MichaelBluejay » Tue Oct 01, 2019 12:07 pm

I'm trying to make a data entry app on my Mac. If you've done data entry, you know that keyboard control is essential; productivity is slowed down dramatically if the user has to constantly waste time going back and forth between the keyboard and the mouse.

My idea is [field] tab >> [field] tab >> [field] >> tab [option menu] type text or use arrow keys, return >> [option menu] type or arrows, return

I get from the last text field to the first option menu with "on tabkey / click at the loc of btn Account1". That drops the menu nicely, but when I hit Return to select a menu item, "on menuPick" does not fire, so the second option menu does not drop. "on menuPick" fires just fine if I drop the menu with a human click on the menu, but of course, I'm trying to handle this from the keyboard.

I'm stumped. Any ideas?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: menuPick doesn't fire if menu was dropped via "click at..."

Post by Klaus » Tue Oct 01, 2019 12:20 pm

Hi Michael,

hm, just made a quick test on my Mac with macOS 10.14.6 and LC 9.5:
One "option menu" button with this script:

Code: Select all

on menuPick pItemName
   put pItemName
end menuPick
So I can see if it works.
Then this in the card script:

Code: Select all

on tabKey
   click at the loc of btn 1
end tabKey
Now when I hit TAB, I can select the menus with the arrow keys and when I hit ENTER or RETURN
I see the selected menuitem in the message box!

Not sure what is going wrong on your side? Can you please post the involved script(s)?


Best

Klaus

MichaelBluejay
Posts: 234
Joined: Thu Jul 01, 2010 11:50 am

Re: menuPick doesn't fire if menu was dropped via "click at..."

Post by MichaelBluejay » Tue Oct 01, 2019 1:09 pm

Thank you very much for the quick reply.

Okay, I stand corrected: menuPick does indeed fire when an item is selected via the keyboard. However, the second option menu just won't drop.

Code: Select all

on menuPick
   wait 1 milliseconds # Next menu doesn't pop unless we wait
   click at the loc of btn Account2_
   put the seconds
end menuPick
The "wait 1 milliseconds" is because even when choosing the menu item with the mouse, the next option menu won't pop unless I put in the delay.

I thought maybe with a keyboard selection I might just have to wait longer, but waiting even 5 seconds doesn't drop the second menu.

I do see "the seconds" populated in the message box.

So, the problem isn't that menuPick isn't firing, it's that the second menu is prejudiced against keyboard input on the first menu.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: menuPick doesn't fire if menu was dropped via "click at..."

Post by Klaus » Tue Oct 01, 2019 1:36 pm

Hi Michael,

ah, get it!
Yep, same here, nothing pops up after the first option menu.
No idea why this is so, but here a workaround, just put the popping of the next menu
into an extra handler and SEND it with a little delay.

This does work for the optionmenu buttons:

Code: Select all

## Optionmenu 1 in my example
on menuPick pItemName
   put pItemName
   send "nextmenu" to me in 1 millisecs
 end menuPick

## This will also go into this button:
## No idea why, but it does work reliably! :-)
command nextmenu
   click at the loc of btn "my option 2"
end nextmenu
Hint: Get used to put QUOTES around names of objects!

Code: Select all

...
   ## click at the loc of btn Account2_
   click at the loc of btn "Account2_"
...
Best

Klaus

MichaelBluejay
Posts: 234
Joined: Thu Jul 01, 2010 11:50 am

Re: menuPick doesn't fire if menu was dropped via "click at..."

Post by MichaelBluejay » Tue Oct 01, 2019 2:23 pm

Thank you, Klaus. You saved my project!

Post Reply