Page 1 of 1

Option Menu using arrows and enter returns nothing in menuPi

Posted: Thu Apr 16, 2015 2:44 am
by bergsy
Hi,

I am having an issue with Option menus.

When I click and select items using the mouse, everything is fine. The pItemName in the menupick function has the value I expect.

If I use arrow keys to align to the option I want and then press enter then the pItemName in the menupick function is empty.

Also, sometimes the vertical scrollbar can't be dragged with the mouse, but that is a lesser issue.

If I change the button type to pulldown menu then the arrow/enter selection works fine, but that is not the interaction I want with the user.

I am wondering what I might be doing wrong, or whether this is functionality I can't expect from an option menu.

Any ideas appreciated

Thanks

Bergsy

Re: Option Menu using arrows and enter returns nothing in me

Posted: Thu Apr 16, 2015 3:01 pm
by dunbarx
Hi.

In order to use the enterKey to invoke an action, you have to trap a message that is generated in that world. Put this in the option button script:

Code: Select all

on enterkey
put the selectedText of me
end enterkey
Craig Newman

EDIT.

Hmmm. I thought this made sense, but it seems that, just like with arrowKeys, no "enterKey" message is sent when inside an "open" hierarchal button. This is related to the thread in the "Talking Livecode" forum "ArrowKeys work and do not work". Fortunately, a menuPick message is indeed sent in either case. See the comments further along in this thread.

Re: Option Menu using arrows and enter returns nothing in me

Posted: Thu Apr 16, 2015 7:42 pm
by jacque
On my Mac, a menupick message is sent after hitting the Enter key and can be handled normally without using an enterkey handler.

Re: Option Menu using arrows and enter returns nothing in me

Posted: Thu Apr 16, 2015 7:58 pm
by dunbarx
Jacque,

Just so. I wanted to allow the OP to perhaps expand his, er, options.

This engendered the thread on arrowKeys and popUps, etc, in the "Talking LiveCode" forum.

Craig

Re: Option Menu using arrows and enter returns nothing in me

Posted: Tue Apr 28, 2015 2:51 am
by bergsy
Seems I didn't submit my previous post on this

The enterkey function never gets hit.....so not sure what to do from here

Re: Option Menu using arrows and enter returns nothing in me

Posted: Tue Apr 28, 2015 2:37 pm
by dunbarx
Hi.

What is happening? If you make a new option menu, and place this in its script:

Code: Select all

on menuPick pItemName
   switch pItemName
      case pItemName
         put pItemName
         break
   end switch
end menuPick
You will get the selected choice in msg when you use the mouse, or use the arrow keys and then hit "enter".

Craig