Problem transferring focus to another object

Terry Judd tsj at
Tue Feb 15 14:41:27 EST 2011

Thanks Craig - I'm trying to create a cross-platform control so
unfortunately I can't use a Mac only option menu. Additionally, I want to
use a small text size in the menu - hence the need to fake a menu with a
field rather than with a proper menu (the overall effect I'm looking for is
like the option menus you see if you do a find (cmd-F in a Finder window on
the Mac). Anyway, it turns out it's not so easy to simulate a menu that
behaves properly when the mouse is both clicked and left open or
continuously held down. I've got it mostly working now - I just have to come
up with a method for closing the menu when the user clicks away from it.


On 16/02/11 1:55 AM, "dunbarx at" <dunbarx at> wrote:
> Hi.
> I am not exactly sure what you need, but I do something similar. I have a
> locked field "class" where I want to place one of several text options. I
> have an option button "class" that I reveal wherever I click the mouse down
> in the field. That button appears at the mouseLoc and I can then select
> something from it. The selected text is loaded into the proper line of the
> field. The button disappears. In the field script:
> on mouseDown
>    set the loc of btn "class" to the clickLoc
>    put  item 2 of the loc of btn "class" into tLoc
>    put trunc((tLoc - the top of me) / the textHeight of me) + 1 into tLine
>    set the clickedLine of me to tLine --remember the line of recent interest
> end mouseDown
> on mouseUp
>       show btn "class" at the clickLoc
>       click at the loc of btn "class"
> end mouseUp
> And in the option button script:
> on menuPick pItemName
>    put  the clickedLine of fld "class" into tLine
>    put pItemname into line tLine  of fld "class"
>    hide me
> end menuPick
> on mouseRelease
>   hide me
> end mouseRelease
> Works fine.
> Craig Newman

Dr Terry Judd | Senior Lecturer in Medical Education
Medical Education Unit
Melbourne Medical School
The University of Melbourne

More information about the Use-livecode mailing list